Example #1
0
#!/usr/bin/env python3

from datetime import datetime

#web3fusion
from web3fsnpy import Fsn

linkToChain = {
    'network': 'mainnet',  # One of 'testnet', or 'mainnet'
    'provider': 'WebSocket',  # One of 'WebSocket', 'HTTP', or 'IPC'
    'gateway': 'wss://mainnetpublicgateway1.fusionnetwork.io:10001',
    #'gateway'     : 'wss://testnetpublicgateway1.fusionnetwork.io:10001',
}

web3fsn = Fsn(linkToChain)

pub_key = "0x3333333333333333333333333333333333333333"

Tckts = web3fsn.ticketsByAddress(pub_key)

#print(Tckts)

print('Total number of tickets: ', len(Tckts))
print('\nor using totalNumberOfTicketsByAddress: ',
      web3fsn.totalNumberOfTicketsByAddress(pub_key), '\n')

for a in Tckts:
    tck = Tckts[a]
    st = datetime.fromtimestamp(tck.StartTime).strftime('%c')
    ex = datetime.fromtimestamp(tck.ExpireTime).strftime('%c')
    print('Block Height: ', tck.Height, ' Start Time: ', st, ' Expiry Time: ',

#web3fusion
from  web3fsnpy import Fsn


linkToChain = {
    'network'     : 'testnet',                          # One of 'testnet', or 'mainnet'
    'provider'    : 'HTTP',                             # One of 'WebSocket', 'HTTP', or 'IPC'
    'gateway'     : 'default',                          # Either set to 'default', or specify your uri endpoint
    #'private_key'                 No private key provided this time
}

#

web3fsn = Fsn(linkToChain)

#pdb.set_trace()

pub_key_sender = "0x3333333333333333333333333333333333333333"
pub_key_receiver = "0x3333333333333333333333333333333333333334"

asset_Id = '0x54cbfda5d4cb46ef1f63d6642f561dcd38dec9fa27a68a0408e9b2b17cc5cfc7'
number_to_transfer = 5  # The number of tokens you wish to send

# Find out some information about this asset
asset_dict = web3fsn.getAsset(asset_Id,'latest')
#print(asset_dict)
print('The asset has the symbol ',asset_dict['Symbol'],' and decimals ',asset_dict['Decimals'])

nonce = web3fsn.getTransactionCount(pub_key_sender)  # Get the nonce for the wallet
Example #3
0
#   Remember to set your environment variables to run this test
#    e.g. export FSN_PRIVATE_KEY=123456789123456789ABCDEF

linkToChain = {
    'network': 'testnet',  # One of 'testnet', or 'mainnet'
    'provider': 'WebSocket',  # One of 'WebSocket', 'HTTP', or 'IPC'
    'gateway':
    'default',  # Either set to 'default', or specify your uri endpoint
    'private_key': os.environ[
        "FSN_PRIVATE_KEY"],  # Do not include (comment out) for just read operations
}

#

web3fsn = Fsn(linkToChain)

#pdb.set_trace()

pub_key_sender = "0x7fbFa5679411a97bb2f73Dd5ad01Ca0822FaD9a6"

nonce = web3fsn.getTransactionCount(
    pub_key_sender)  # Get the nonce for the wallet

# Construct the transaction

transaction = {
    'from': pub_key_sender,
    'nonce': nonce,
}
Example #4
0
#!/usr/bin/env python3

#web3fusion
from  web3fsnpy import Fsn
from datetime import datetime

linkToChain = {
    'network'     : 'mainnet',     # One of 'testnet', or 'mainnet'
    'provider'    : 'WebSocket',   # One of 'WebSocket', 'HTTP', or 'IPC'
    'gateway'     : 'wss://mainnetpublicgateway1.fusionnetwork.io:10001',
    #'gateway'     : 'wss://testnetpublicgateway1.fusionnetwork.io:10001',
}

web3fsn = Fsn(linkToChain)

# Get the ticket price 

ticket_price = web3fsn.ticketPrice()
ticket_price = web3fsn.fromWei(ticket_price,'ether')

print('\nThe ticket price = ',ticket_price,' FSN')

input('Hit a key to continue ')


# Get the staking information

stake_info = web3fsn.getStakeInfo()
#print(stake_info)

for node in range(stake_info.summary.totalMiners):
Example #5
0
from  web3fsnpy import Fsn
import os
import sys
from eth_utils import (
    to_hex,
)
from datetime import datetime, timedelta
#import pdb ; pdb.set_trace()

linkToChain = {
    'network'     : 'mainnet',     # One of 'testnet', or 'mainnet'
    'provider'    : 'WebSocket',   # One of 'WebSocket', 'HTTP', or 'IPC'
    'gateway'     : 'default',
}

web3fsn = Fsn(linkToChain)


#
pub_key = '0x3333333333333333333333333333333333333333'
asset_name = 'FSN'
blockNo = 'latest'
#
#
asset_Id = web3fsn.getAssetId(asset_name)
#
asset_timelocks = web3fsn.getTimeLockBalance(asset_Id, pub_key, blockNo)
#
print(asset_timelocks,'\n')
#
#
Example #6
0
#   Remember to set your environment variable to run this test
#    e.g. export FSN_PRIVATE_KEY=123456789123456789ABCDEF

linkToChain = {
    'network': 'testnet',  # One of 'testnet', or 'mainnet'
    'provider': 'WebSocket',  # One of 'WebSocket', 'HTTP', or 'IPC'
    'gateway':
    'default',  # Either set to 'default', or specify your uri endpoint
    'private_key': os.environ[
        "FSN_PRIVATE_KEY"],  # Do not include (comment out) for just read, or signed raw transactions
}

#

web3fsn = Fsn(linkToChain)

pub_key = '0x3333333333333333333333333333333333333333'

print('Is autoBuyTicket set? : ', web3fsn.isAutoBuyTicket())

nonce = web3fsn.getTransactionCount(pub_key)  # Get the nonce for the wallet

# Construct the transaction
#

transaction = {
    'from': pub_key,
    'nonce': nonce,
}
# Get the private key from your staking wallet by looking under the 'Your details' tab
# in the window that you will run this programme, type:-
#
#    export FSN_PRIVATE_KEY='XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
#
private_key_sender = os.environ[
    "FSN_PRIVATE_KEY"]  # This is the private key of your STAKING WALLET
#
linkToChain = {
    'network': 'mainnet',  # One of 'testnet', or 'mainnet'
    'provider': 'WebSocket',  # One of 'WebSocket', 'HTTP', or 'IPC'
    'gateway': 'default',
    'private_key': private_key_sender,
}
#
web3fsn = Fsn(linkToChain)  # This connects to the block chain
#
asset_name = 'FSN'
asset_Id = web3fsn.getAssetId(asset_name)
blockNo = 'latest'
#
pub_key_staking = web3fsn.acct.address
print('pub_key_staking = ', pub_key_staking)
#
if send_email:
    subject = 'Fusion Rewards for ' + VPS_name  # email subject header
#
#
transaction = {
    "from": pub_key_staking,
    "to": pub_key_main,
Example #8
0
#   Remember to set your environment variables to run this test
#    e.g. export FSN_PRIVATE_KEY=123456789123456789ABCDEF 



linkToChain = {
    'network'     : 'testnet',                          # One of 'testnet', or 'mainnet'
    'provider'    : 'IPC',                              # One of 'WebSocket', 'HTTP', or 'IPC'
    'gateway'     : 'default',                          # Either set to 'default', or specify your uri endpoint
    'private_key'     : os.environ["FSN_PRIVATE_KEY"],  # Do not include (comment out) for just read operations
}

#

web3fsn = Fsn(linkToChain)

#pdb.set_trace()

pub_key_sender = "0x3333333333333333333333333333333333333333"



nonce = web3fsn.getTransactionCount(pub_key_sender)  # Get the nonce for the wallet

# Construct the transaction

transaction = {
  "from":       pub_key_sender,
  "name":       "TestCoin",
  "nonce":       nonce,
Example #9
0
#   Remember to set your environment variables to run this test
#    e.g. export FSN_PRIVATE_KEY=123456789123456789ABCDEF

linkToChain = {
    'network': 'testnet',  # One of 'testnet', or 'mainnet'
    'provider': 'HTTP',  # One of 'WebSocket', 'HTTP', or 'IPC'
    'gateway':
    'default',  # Either set to 'default', or specify your uri endpoint
    'private_key': os.environ[
        "FSN_PRIVATE_KEY"],  # Do not include (comment out) for just read operations
}

#

web3fsn = Fsn(linkToChain)

#pdb.set_trace()

pub_key_sender = "0x3333333333333333333333333333333333333333"
pub_key_receiver = "0x3333333333333333333333333333333333333334"

asset_Id = '0x5fd3f254ae34bf9bf9dc46f72e4fbbc75844dbe6823f970fa3f7aaedb2925ff6'
number_to_transfer = 5  # The number of tokens you wish to send

# Find out some information about this asset
asset_dict = web3fsn.getAsset(asset_Id, 'latest')
#print(asset_dict)
print('The asset has the symbol ', asset_dict['Symbol'], ' and decimals ',
      asset_dict['Decimals'])
Example #10
0
#!/usr/bin/env python3

#web3fusion
from web3fsnpy import Fsn

linkToChain = {
    'network': 'testnet',  # One of 'testnet', or 'mainnet'
    'provider': 'HTTP',  # One of 'WebSocket', 'HTTP', or 'IPC'
    'gateway': 'default',
}

web3fsn = Fsn(linkToChain)

#
asset_name = 'FSN'
blockNo = 'latest'
#
#
asset_Id = web3fsn.getAssetId(
    asset_name
)  # Or you can put the asset ID as a hex number here if it is not a 'standard' asset.
#
pub_key = '0x3333333333333333333333333333333333333333'
#
bal = web3fsn.getBalance(pub_key, asset_Id, blockNo)
#
#
print('Balance for ', pub_key, ' is  ', web3fsn.fromWei(int(bal), 'ether'),
      ' FSN')
#
#
Example #11
0
#   Remember to set your environment variable to run this test
#    e.g. export FSN_PRIVATE_KEY=123456789123456789ABCDEF 



linkToChain = {
    'network'     : 'testnet',                          # One of 'testnet', or 'mainnet'
    'provider'    : 'WebSocket',                        # One of 'WebSocket', 'HTTP', or 'IPC'
    'gateway'     : 'default',                          # Either set to 'default', or specify your uri endpoint
    'private_key'     : os.environ["FSN_PRIVATE_KEY"],  # Do not include (comment out) for just read, or signed raw transactions
}

#

web3fsn = Fsn(linkToChain)


pub_key = '0x7fbFa5679411a97bb2f73Dd5ad01Ca0822FaD9a6'  # For a private swap

swapInfo = web3fsn.getAllSwaps()

#print(swapInfo)

for swp in swapInfo:
    print('SwapID : {} From asset : {} To asset : {} Size : {} MinFromAmount : {} MinToAmount : {} SwapSize : {}\n'
          .format(swp['swapID'],swp['fromAsset'],swp['toAsset'],swp['size'],
          swp['MinFromAmount'],swp['MinToAmount'],swp['SwapSize']))

swapID = input('Enter a swapID from the above list  ')
Example #12
0
#   Remember to set your environment variable to run this test
#    e.g. export FSN_PRIVATE_KEY=123456789123456789ABCDEF 



linkToChain = {
    'network'     : 'testnet',                          # One of 'testnet', or 'mainnet'
    'provider'    : 'WebSocket',                        # One of 'WebSocket', 'HTTP', or 'IPC'
    'gateway'     : 'default',                          # Either set to 'default', or specify your uri endpoint
    'private_key'     : os.environ["FSN_PRIVATE_KEY"],  # Do not include (comment out) for just read, or signed raw transactions
}

#

web3fsn = Fsn(linkToChain)


pub_key_sender = "0x3333333333333333333333333333333333333333"
pub_key_receiver = "0x3333333333333333333333333333333333333334"

asset_Id = '0x3ddec7217915b0c145da683402cfbb94c1b160d23a432f75a39e33e2db091437'
number_to_transfer = 5  # The number of tokens you wish to send

# Find out some information about this asset
asset_dict = web3fsn.getAsset(asset_Id,'latest')
#print(asset_dict)
asset_name = asset_dict['Symbol']
print('The asset has the symbol ',asset_name,' and decimals ',asset_dict['Decimals'])

#!/usr/bin/env python3
#
# Demonstrate getting asset information
#
#
#web3fusion
from web3fsnpy import Fsn

linkToChain = {
    'network': 'testnet',  # One of 'testnet', or 'mainnet'
    'provider': 'WebSocket',  # One of 'WebSocket', 'HTTP', or 'IPC'
    'gateway': 'default',
}

web3fsn = Fsn(linkToChain)
#
#
asset_name = 'FSN'
#
#
assetInfo = web3fsn.assetNameToAssetInfo(asset_name)
#
print(assetInfo)
#
Example #14
0
#!/usr/bin/env python3

#web3fusion
from web3fsnpy import Fsn

linkToChain = {
    'network': 'testnet',  # One of 'testnet', or 'mainnet'
    'provider': 'WebSocket',  # One of 'WebSocket', 'HTTP', or 'IPC'
    'gateway': 'default',
}

web3fsn = Fsn(linkToChain)

print('Current block height is ', web3fsn.blockNumber)
Example #15
0
#!/usr/bin/env python3
#
# Demonstrate getting asset information
#
#
#web3fusion
from web3fsnpy import Fsn

linkToChain = {
    'network': 'testnet',  # One of 'testnet', or 'mainnet'
    'provider': 'WebSocket',  # One of 'WebSocket', 'HTTP', or 'IPC'
    'gateway': 'default',
}

web3fsn = Fsn(linkToChain)
#
#
#asset_name = 'FSN'
asset_name = 'TST5'
blockNo = 'latest'
#
#
asset_Id = web3fsn.getAssetId(asset_name)
print('asset_Id = ', asset_Id)
#
if asset_Id != None:
    asset_dict = web3fsn.getAsset(asset_Id, blockNo)
    #
    #   print(asset_dict,'\n')
    #
    #
Example #16
0
#   Remember to set your environment variable to run this test
#    e.g. export FSN_PRIVATE_KEY=123456789123456789ABCDEF 



linkToChain = {
    'network'     : 'testnet',                          # One of 'testnet', or 'mainnet'
    'provider'    : 'WebSocket',                        # One of 'WebSocket', 'HTTP', or 'IPC'
    'gateway'     : 'default',                          # Either set to 'default', or specify your uri endpoint
    'private_key'     : os.environ["FSN_PRIVATE_KEY"],  # Do not include (comment out) for just read, or signed raw transactions
}

#

web3fsn = Fsn(linkToChain)


pub_key_sender = "0x3333333333333333333333333333333333333333"
pub_key_receiver = "0x3333333333333333333333333333333333333333"

asset_Id = '0x5fd3f254ae34bf9bf9dc46f72e4fbbc75844dbe6823f970fa3f7aaedb2925ff6'
number_to_transfer = 5  # The number of tokens you wish to send

# Find out some information about this asset
asset_dict = web3fsn.getAsset(asset_Id,'latest')
#print(asset_dict)
asset_name = asset_dict['Symbol']
print('The asset has the symbol ',asset_name,' and decimals ',asset_dict['Decimals'])

Example #17
0
#!/usr/bin/env python3

#web3fusion
from web3fsnpy import Fsn

linkToChain = {
    'network': 'mainnet',  # One of 'testnet', or 'mainnet'
    'provider': 'WebSocket',  # One of 'WebSocket', 'HTTP', or 'IPC'
    'gateway': 'wss://mainnetpublicgateway1.fusionnetwork.io:10001',
    #'gateway'     : 'wss://testnetpublicgateway1.fusionnetwork.io:10001',
}

web3fsn = Fsn(linkToChain)

TxID = 0x25557995e5ed36cc41c156e7f8fa7be10c6d45e25e37cd2e1f8d2d443480b2f2

Tx = web3fsn.getTransaction(TxID)

print(Tx)  # Print the whole dictionary

#print('from        : ',Tx.from)
#print('to          : ',Tx.to)
#print('blocknumber : ',Tx.blockNumber)

TxCount = web3fsn.getBlockTransactionCount(Tx.blockNumber)

print('There were ', TxCount, ' transactions in block number ', Tx.blockNumber)
Example #18
0
#   Remember to set your environment variables to run this test
#    e.g. export FSN_PRIVATE_KEY=123456789123456789ABCDEF

linkToChain = {
    'network': 'testnet',  # One of 'testnet', or 'mainnet'
    'provider': 'HTTP',  # One of 'WebSocket', 'HTTP', or 'IPC'
    'gateway':
    'default',  # Either set to 'default', or specify your uri endpoint
    'private_key': os.environ[
        "FSN_PRIVATE_KEY"],  # Do not include (comment out) for just read, or signed raw transactions
}

#

web3fsn = Fsn(linkToChain)

#pdb.set_trace()

if not web3fsn.isConnected():
    raise ('Did not connect to gateway ', linkToChain['gateway'])

#

pub_key_sender = "0x3333333333333333333333333333333333333333"
pub_key_receiver = "0x3333333333333333333333333333333333333334"

value = web3fsn.toWei(0.02, 'ether')  # How much FSN are we sending?

nonce = web3fsn.getTransactionCount(
    pub_key_sender)  # Get the nonce for the sending wallet
Example #19
0
#import pdb ; pdb.set_trace()

#web3fusion
from web3fsnpy import Fsn

linkToChain = {
    'network': 'testnet',  # One of 'testnet', or 'mainnet'
    'provider': 'HTTP',  # One of 'WebSocket', 'HTTP', or 'IPC'
    'gateway':
    'default',  # Either set to 'default', or specify your uri endpoint
    #    'private_key'     : os.environ["FSN_PRIVATE_KEY"],  # Do not include (comment out) for just read, or signed raw transactions
}

#

web3fsn = Fsn(linkToChain)

pageNo = 0  # Only get the most recent 100 records on the first page

swap_dict = web3fsn.getAllSwaps(pageNo)

print('No. swaps = ', len(swap_dict), '\n')

for ii in range(len(swap_dict)):
    for key, value in swap_dict[ii].items():
        if key == 'timeStamp' or key == 'FromStartTime' or key == 'ToEndTime' or key == 'Time':
            value = web3fsn.numToDatetime(value)
        elif key == 'fromAsset' or key == 'toAsset':
            if value == web3fsn.tokens['FSN']:
                value = 'FSN'
        print(key, value)
#
# Demonstrate getting timelock balances information
#
#web3fusion
from web3fsnpy import Fsn

import os
import sys
from eth_utils import (
    to_hex, )
from datetime import datetime, timedelta

linkToChain = {
    'network': 'mainnet',  # One of 'testnet', or 'mainnet'
    'provider': 'HTTP',  # One of 'WebSocket', 'HTTP', or 'IPC'
    'gateway': 'default',
}

web3fsn = Fsn(linkToChain)

#
pub_key = '0x3333333333333333333333333333333333333333'
blockNo = 'latest'
#
#
asset_timelocks = web3fsn.getAllTimeLockBalances(pub_key,
                                                 block_identifier=None)
#
print(asset_timelocks, '\n')
#
Example #21
0
#   Remember to set your environment variable to run this test
#    e.g. export FSN_PRIVATE_KEY=123456789123456789ABCDEF

linkToChain = {
    'network': 'testnet',  # One of 'testnet', or 'mainnet'
    'provider': 'WebSocket',  # One of 'WebSocket', 'HTTP', or 'IPC'
    'gateway':
    'default',  # Either set to 'default', or specify your uri endpoint
    'private_key': os.environ[
        "FSN_PRIVATE_KEY"],  # Do not include (comment out) for just read, or signed raw transactions
}

#

web3fsn = Fsn(linkToChain)

pub_key_sender = "0x3333333333333333333333333333333333333333"
pub_key_receiver = "0x3333333333333333333333333333333333333334"  # For a private swap

assetId_TST1 = '0x3ddec7217915b0c145da683402cfbb94c1b160d23a432f75a39e33e2db091437'
assetId_TST2 = '0x34ab2db7e4e5a69e5ec1441d580b9e9599e806cbecf821b87bf4a5952e27ee21'

number_to_swap = 5  # The minimum number of tokens you wish to swap
number_to_receive = 1  # The minimum number of tokens you wish to receive

# Find out some information about these assets
asset_dict = web3fsn.getAsset(assetId_TST1, 'latest')
asset_TST1_name = asset_dict['Symbol']
asset_TST1_decimals = asset_dict['Decimals']