FACTORY_ADDRESS = sys.argv[4]
token_1_address = sys.argv[5]
token_2_address = sys.argv[6]

if not token_1_address:
    raise Exception("fill out the token 1 smart contract address")

if not token_2_address:
    raise Exception("fill out the token 2 smart contract address")

# Prepare wallet and network
w = Wallet.fromPrivateKey(bytes.fromhex(PRIVATE_KEY))
c = Connect(NETWORK)
factory_contract = Contract.fromFile(FACTORY_FILE)

if not utils.is_contract(c.get_account(FACTORY_ADDRESS)):
    raise Exception(f"{FACTORY_ADDRESS} is not a smart contract")

if not utils.is_contract(c.get_account(token_1_address)):
    raise Exception(f"{token_1_address} is not a smart contract")

if not utils.is_contract(c.get_account(token_2_address)):
    raise Exception(f"{token_2_address} is not a smart contract")

# Call on factory to create a pool of token 1 and token 2
response = c.transact(w, factory_contract, 'createPair',
                      [token_1_address, token_2_address], FACTORY_ADDRESS)
tx_id = response['id']

# Wait for Receipt
receipt = c.wait_for_tx_receipt(tx_id, 30)
Ejemplo n.º 2
0
SLEEP = 11

# Read in Params
SCRIPT_NAME = sys.argv[0]
NETWORK = sys.argv[1]  # eg. 'https://solo.veblocks.net'
PRIVATE_KEY = sys.argv[2]
COMTRACT_FILE = sys.argv[3]
CONTRACT_ADDRESS = sys.argv[4]

# Prepare wallet and network
w = Wallet.fromPrivateKey(bytes.fromhex(PRIVATE_KEY))
c = Connect(NETWORK)
smart_contract = Contract.fromFile(COMTRACT_FILE)

# Detect wallet balance
account = c.get_account(w.getAddress())
print('Wallet:')
print('VET:', int(account['balance'], 16) / (10**18))
print('VTHO:', int(account['energy'], 16) / (10**18))
print('Is human:', not utils.is_contract(account))

# Emulate the call of getting a random number
if not utils.is_contract(c.get_account(CONTRACT_ADDRESS)):
    raise Exception(f"{CONTRACT_ADDRESS} is not a smart contract")

# best block
# block = c.get_block()
# best_block_number = int(block['number'])
winners = set()
best_block_number = 8859801
for i in range(200):
PRIVATE_KEY = sys.argv[2]
FACTORY_FILE = sys.argv[3]
ROUTER_FILE = sys.argv[4]
VVET_CONTRACT_ADDRESS = sys.argv[5]

# Prepare wallet and network
w = Wallet.fromPrivateKey(bytes.fromhex(PRIVATE_KEY))
c = Connect(NETWORK)
factory_contract = Contract.fromFile(FACTORY_FILE)
router_contract = Contract.fromFile(ROUTER_FILE)
vvet_contract_address = VVET_CONTRACT_ADDRESS
if not vvet_contract_address:
    raise Exception("Set vVET contract address first!")

# Detect if VVET contract is ready
a = c.get_account(vvet_contract_address)
if not utils.is_contract(a):
    raise Exception(f"{vvet_contract_address} is not a smart contract")

# Detect wallet balance
account = c.get_account(w.getAddress())
print('Wallet balance:')
print('VET:', int(account['balance'], 16) / (10**18))
print('VTHO:', int(account['energy'], 16) / (10**18))
print('Is human:', not utils.is_contract(account))

# Deploy Factory
fee_to_setter = w.getAddress()  # fee to setter is me.
response = c.deploy(w, factory_contract, ['address', 'address'],
                    [fee_to_setter, vvet_contract_address])
tx_id = response['id']
Ejemplo n.º 4
0
from thor_requests.wallet import Wallet
from thor_requests.contract import Contract
from thor_requests import utils
# Read in Params
SCRIPT_NAME = sys.argv[0]
NETWORK = sys.argv[1]  # eg. 'https://solo.veblocks.net'
PRIVATE_KEY = sys.argv[2]
VVET_FILE = sys.argv[3]

# Prepare wallet and network
w = Wallet.fromPrivateKey(bytes.fromhex(PRIVATE_KEY))
c = Connect(NETWORK)
vvet_contract = Contract.fromFile(VVET_FILE)

# Detect wallet balance
account = c.get_account(w.getAddress())
print('Wallet:')
print('VET:', int(account['balance'], 16) / (10**18))
print('VTHO:', int(account['energy'], 16) / (10**18))
print('Is human:', not utils.is_contract(account))

# Deploy
response = c.deploy(w, vvet_contract, None, None)
tx_id = response['id']
print('deploy_vvet_tx:', tx_id)

# Wait for Receipt
receipt = c.wait_for_tx_receipt(tx_id, 30)
if not receipt:
    raise Exception(f"receipt not found! by tx id: {tx_id}")
token_1_amount = int(sys.argv[8])
token_2_amount = int(sys.argv[9])

if not token_1_address:
    raise Exception("fill out the token 1 smart contract address")

if not token_2_address:
    raise Exception("fill out the token 2 smart contract address")

# Prepare wallet, network, contract
w = Wallet.fromPrivateKey(bytes.fromhex(PRIVATE_KEY))
c = Connect(NETWORK)
router02_contract = Contract.fromFile(ROUTER02_FILE)
erc20_contract = Contract.fromFile(ERC20_FILE)

if not utils.is_contract(c.get_account(ROUTER02_ADDRESS)):
    raise Exception(f"{ROUTER02_ADDRESS} is not a smart contract")

if not utils.is_contract(c.get_account(token_1_address)):
    raise Exception(f"{token_1_address} is not a smart contract")

if not utils.is_contract(c.get_account(token_2_address)):
    raise Exception(f"{token_2_address} is not a smart contract")

# Call to approve() vtho to be used by router02
response = c.transact(w, erc20_contract, 'approve',
                      [ROUTER02_ADDRESS, token_2_amount], token_2_address)
tx_id = response['id']
receipt = c.wait_for_tx_receipt(tx_id, 30)
if not receipt:
    raise Exception(f"receipt not found! by tx id: {tx_id}")