Ejemplo n.º 1
0
def generateAccounts():
    # generate accounts 1 and 2
    private_key_1, address_1 = account.generate_account()
    private_key_2, address_2 = account.generate_account()
    private_key_3, address_3 = account.generate_account()
    account_1 = {
        "pkey": private_key_1,
        "alc_address": address_1,
        "alc_information": forAlcInfo.account_info(address_1)
    }
    account_2 = {
        "pkey": private_key_2,
        "alc_address": address_2,
        "alc_information": forAlcInfo.account_info(address_2)
    }
    account_3 = {
        "pkey": private_key_3,
        "alc_address": address_3,
        "alc_information": forAlcInfo.account_info(address_3)
    }
    # store accounts 1 and 2
    accounts["account_1"] = account_1
    accounts["account_2"] = account_2
    accounts["account_3"] = account_3
    return (accounts)
Ejemplo n.º 2
0
    def test_errors(self):

        # get random private key
        private_key_1, account_1 = account.generate_account()
        private_key_2, account_2 = account.generate_account()
        private_key_3, account_3 = account.generate_account()

        # create transaction
        gh = "JgsgCaCTqIaLeVhyL6XlRu3n7Rfk2FxMeK+wRSaQ7dI="
        txn = transaction.PaymentTxn(account_2, 3, 1234, 1334, gh, account_2,
                                     1000)

        # create multisig address with invalid version
        msig = transaction.Multisig(2, 2, [account_1, account_2])
        self.assertRaises(error.UnknownMsigVersionError, msig.validate)

        # change it to have invalid threshold
        msig.version = 1
        msig.threshold = 3
        self.assertRaises(error.InvalidThresholdError, msig.validate)

        # try to sign multisig transaction
        msig.threshold = 2
        mtx = transaction.MultisigTransaction(txn, msig)
        self.assertRaises(error.BadTxnSenderError, mtx.sign, private_key_1)

        # change sender address to be correct
        txn.sender = msig.address()
        mtx = transaction.MultisigTransaction(txn, msig)

        # try to sign with incorrect private key
        self.assertRaises(error.InvalidSecretKeyError, mtx.sign, private_key_3)

        # create another multisig with different address
        msig_2 = transaction.Multisig(1, 2, [account_2, account_3])

        # try to merge with different addresses
        mtx_2 = transaction.MultisigTransaction(txn, msig_2)
        self.assertRaises(error.MergeKeysMismatchError,
                          transaction.MultisigTransaction.merge, [mtx, mtx_2])

        # create another multisig with same address
        msig_3 = msig_2.get_multisig_account()

        # add mismatched signatures
        msig_2.subsigs[0].signature = "sig2"
        msig_3.subsigs[0].signature = "sig3"

        # try to merge
        self.assertRaises(error.DuplicateSigMismatchError,
                          transaction.MultisigTransaction.merge, [
                              transaction.MultisigTransaction(txn, msig_2),
                              transaction.MultisigTransaction(txn, msig_3)
                          ])
Ejemplo n.º 3
0
def create_trashbag():
    kcl = kmd.KMDClient(params.kmd_token, params.kmd_address)
    acl = algod.AlgodClient(params.algod_token, params.algod_address)

    petitionWallet = "Petitions"
    petitionWalletPassword = "******"

    # get the wallet ID
    wallets = kcl.list_wallets()

    petitionWalletID = None
    for w in wallets:
        if w["name"] == petitionWallet:
            petitionWalletID = w["id"]
            break

    # if it doesn't exist, create the wallet and get its ID
    if not petitionWalletID:
        petitionWalletID = kcl.create_wallet(petitionWallet,
                                             petitionWalletPassword)["id"]

    # get a handle for the wallet
    handle = kcl.init_wallet_handle(petitionWalletID, petitionWalletPassword)
    # generate account with account and check if it's valid
    private_key_1, address_1 = account.generate_account()
    # import generated account into the wallet
    kcl.import_key(handle, private_key_1)
    """Creates trash bag account for all petitions."""
    petition = Petition(name="Trash Bag Account",
                        publicKey=address_1,
                        masterAccount=address_1,
                        yesCount=0)
    db.session.add(petition)
    db.session.commit()
Ejemplo n.º 4
0
def create_account(update, context):
    """
    Create new public/private key pair
    Returns the result of generating an account to user:
    :param update:
    :param context:
    :return: 1). An Algorand address, 2). A mnemonic seed phrase
    """
    update.message.reply_text("Hang on while I get you an account ...")
    time.sleep(1)
    try:
        sk, pk = account.generate_account()
        mn = mnemonic.from_private_key(sk)
        if not (pk and sk is None):
            update.message.reply_text("Account creation success.\nAddress:  {}\n\n"
                                      "Private Key:  {}\n\n"
                                      "Mnemonic:\n {}\n\n"
                                      "I do not hold or manage your keys."
                                      "".format(pk, sk, mn)
                                      )
            context.user_data['default_pk'] = pk
        update.message.reply_text('To test if your address works fine, copy your address, and visit:\n ')
        keyboard = [[InlineKeyboardButton(
            "DISPENSER", 'https://bank.testnet.algorand.network/', callback_data='1')]]

        dispenser = InlineKeyboardMarkup(keyboard)

        update.message.reply_text('the dispenser to get some Algos\nSession ended.'
                                  'Click /start to begin.', reply_markup=dispenser)
    except Exception as e:
        update.message.reply_text('Account creation error.')
        return e
Ejemplo n.º 5
0
def create_account(role):
    """ Create new account """
    RECEIVER_PRIVATE_KEY, RECEIVER_ADDRESS = account.generate_account()
    amount = 0
    algo_amount = 301000
    message = ''
    if role == 'player':
        amount = 1500
        message = 'Your account has been created with 1,500 Monopoly Money. Scan QR code.'

    elif role == 'banker':
        amount = 20000
        message = 'Your account has been created with 20,000 Monopoly Money. Scan QR code. '

    # Send 0.301 Algo to new account (for opt-in and transaction fees)
    algo_transaction(SENDER_ADDRESS, SENDER_PRIVATE_KEY, RECEIVER_ADDRESS, algo_amount)

    # Opt-in Monopoly Money Asset
    asset_transfer(RECEIVER_ADDRESS, RECEIVER_PRIVATE_KEY, RECEIVER_ADDRESS, 0, ASSET_ID)

    # Send Monopoly Money ASA
    asset_transfer(SENDER_ADDRESS, SENDER_PRIVATE_KEY, RECEIVER_ADDRESS, amount, ASSET_ID)

    # Create PNG file with QR-code which store the passphrase
    passphrase = '{{"version":"1.0", "mnemonic":"{}"}}'.format(mnemonic.from_private_key(RECEIVER_PRIVATE_KEY))
    qr_code = pyqrcode.create(passphrase)
    rnd = random.random()
    qr_file = 'static/{}{}.png'.format(RECEIVER_ADDRESS, str(rnd))
    qr_code.png(qr_file, scale=6)
    return qr_file, message
Ejemplo n.º 6
0
 def test_verify_negative(self):
     sk, pk = account.generate_account()
     intarray = [random.randint(0, 255) for x in range(15)]
     message = bytes(intarray)
     signature = util.sign_bytes(message, sk)
     intarray[0] = (intarray[0] + 1) % 256
     changed_message = bytes(intarray)
     self.assertFalse(util.verify_bytes(changed_message, signature, pk))
Ejemplo n.º 7
0
def create_wallet():
    """
    Creates an Algorand wallet and returns the mnemonic of the new wallet.
    @returns a string of the 25-word passphrase
    """
    private_key, account_address = account.generate_account()
    passphrase = mnemonic.from_private_key(private_key)
    return passphrase
Ejemplo n.º 8
0
def setup_cmo():
    private_key, account = account_algosdk.generate_account()
    # passphrase1 = "faint fog unfair treat enemy disagree host merit bulb lizard client proof aspect cruise vital lion gate victory planet grace weird food phrase absent marriage"
    # private_key = mnemonic.to_private_key(passphrase1)
    # account = account_algosdk.address_from_private_key(private_key)
    print("CMO address: {}".format(account))
    print("CMO passphrase: {}".format(mnemonic.from_private_key(private_key)))
    return  account, private_key
Ejemplo n.º 9
0
def generate_new_account():
    """
	Generate a new Algorand account and print the public address
	and private key mnemonic.
	"""
    private_key, public_address = account.generate_account()
    passphrase = mnemonic.from_private_key(private_key)
    print("Address: {}\nPassphrase: \"{}\"".format(public_address, passphrase))
Ejemplo n.º 10
0
    def generate(cls) -> "Wallet":
        """
        Generates a public/private key pair

        Returns:
            wallet: an instance of the class Wallet with the generated keys
        """
        private_key, public_key = generate_account()
        return cls(private_key, public_key)
Ejemplo n.º 11
0
def create_event(name):
    al = algod.AlgodClient(al_token, al_address)
    key, address = account.generate_account()
    eid = len(read_events()) + 1
    return {
        "name": name,
        "id": eid,
        "private_key": key,
        "address": address
    }
Ejemplo n.º 12
0
def find_address(pattern, queue, count):
    while True:
        with count.get_lock():
            count.value += 1

        # generate an account using algosdk
        private_key, address = account.generate_account()

        if address.startswith(pattern):
            queue.put((address, private_key))
            break
Ejemplo n.º 13
0
def generate_algorand_keypair():
    print("## START keypair generator ##\n")

    private_key, address = account.generate_account()
    print("New address: {}".format(address))
    print("New passphrase: {}".format(mnemonic.from_private_key(private_key)) +
          "\n")

    print("# END keypair generator #\n")

    return (private_key, address)
Ejemplo n.º 14
0
def generate_new_account():
    """
    Generate a new Algorand account and print the public address
    and private key mnemonic.
    """
    private_key, public_address = account.generate_account()
    passphrase = mnemonic.from_private_key(private_key)
    return json.dumps({
        "Address": public_address,
        "Key": private_key,
        "Passphrase": passphrase
    })
Ejemplo n.º 15
0
def create_New_Account(
    wallet_id, wallet_pass
):  #Taken from algorand example.py, changed the variable name to more suitable one
    wallet_handle = kcl.init_wallet_handle(wallet_id, wallet_pass)
    account_private_key, account_address = account.generate_account()
    kcl.import_key(
        handle,
        accouunt_private_key)  # import generated account into the wallet
    mnemonice_phrase = mnemonic.from_private_key(account_private_key)
    print("Wallet handle token: " + handle + "\n")
    print("Private key: " + account_private_key + "\n")
    print("Account address: " + account_address)
    print("Mnemonic phrase generated for the account:(Keep it safe) " +
          mnemonice_phrase + "\n")
    algosdk.algod.account_info(address, **kwargs)
Ejemplo n.º 16
0
def get_test_account(update, context):
    """
    Create new public/private key pair
    Returns the result of generating an account to user:
    :param update:
    :param context:
    :return: 1). An Algorand address, 2). A mnemonic seed phrase
    """
    global mn

    update.message.reply_text("Swift!\nYour keys are ready: \n")
    try:
        sk, pk = account.generate_account()
        mn = mnemonic.from_private_key(sk)
        address = account.address_from_private_key(sk)
        update.message.reply_text("Account address/Public key:  {}\n\n"
                                  "Private Key:  {}\n\n"
                                  "Mnemonic:\n {}\n\n"
                                  "I do not hold or manage your keys."
                                  "".format(address, sk, mn))
        context.user_data['default_pk'] = pk
        update.message.reply_text(
            'To test if your address works fine, copy your address, and visit:\n '
        )
        key_board = [[
            InlineKeyboardButton("DISPENSER",
                                 'https://bank.testnet.algorand.network/',
                                 callback_data='1')
        ]]

        dispenser = InlineKeyboardMarkup(key_board)

        update.message.reply_text(
            'the dispenser to get some Algos\nSession ended.'
            'Click /start to begin.',
            reply_markup=dispenser)
        context.user_data.clear()
    except Exception as e:
        update.message.reply_text('Account creation error.')
        return e
Ejemplo n.º 17
0
def create_account(fund=True):
    # Change algod_token and algod_address to connect to a different client
    algod_token = "2f3203f21e738a1de6110eba6984f9d03e5a95d7a577b34616854064cf2c0e7b"
    algod_address = "https://academy-algod.dev.aws.algodev.network/"
    algod_client = algod.AlgodClient(algod_token, algod_address)

    #Generate new account for this transaction
    secret_key, my_address = account.generate_account()
    m = mnemonic.from_private_key(secret_key)
    print("My address: {}".format(my_address))

    # Check your balance. It should be 0 microAlgos
    account_info = algod_client.account_info(my_address)
    print("Account balance: {} microAlgos".format(account_info.get('amount')) +
          "\n")

    if fund:
        #Fund the created account
        print(
            'Go to the below link to fund the created account using testnet faucet: \n https://dispenser.testnet.aws.algodev.network/?account={}'
            .format(my_address))

        completed = ""
        while completed.lower() != 'yes':
            completed = input("Type 'yes' once you funded the account: ")

        print('Fund transfer in process...')
        # Wait for the faucet to transfer funds
        time.sleep(5)

        print('Fund transferred!')
        # Check your balance. It should be 5000000 microAlgos
        account_info = algod_client.account_info(my_address)
        print("Account balance: {} microAlgos".format(
            account_info.get('amount')) + "\n")

    return m
Ejemplo n.º 18
0
def create_bid(context):
    context.sk, pk = account.generate_account()
    context.bid = auction.Bid(pk, 1, 2, 3, pk, 4)
Ejemplo n.º 19
0
def gen_key(context):
    context.sk, context.pk = account.generate_account()
    context.old = context.pk
Ejemplo n.º 20
0
# Example: accepting assets

from algosdk import account
from algosdk.future import transaction

private_key, address = account.generate_account()

fee_per_byte = 10
first_valid_round = 1000
last_valid_round = 2000
genesis_hash = "SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI="
receiver = address  # to start accepting assets, set receiver to sender
amount = 0  # to start accepting assets, set amount to 0

index = 1234  # identifying index of the asset

# create the asset accept transaction
sp = transaction.SuggestedParams(fee_per_byte, first_valid_round,
                                 last_valid_round, genesis_hash)
txn = transaction.AssetTransferTxn(address, sp, receiver, amount, index)

# sign the transaction
signed_txn = txn.sign(private_key)
Ejemplo n.º 21
0
def createPetition():
    form = CreatePetitionForm(request.form)
    if form.validate_on_submit():
        petitionWallet = "Petitions"
        petitionWalletPassword = "******"
        masterAccountWallet = "MasterAccounts"
        masterAccountWalletPassword = "******"
        wallets = kcl.list_wallets()
        petitionWalletID = None
        for w in wallets:
            if w["name"] == petitionWallet:
                petitionWalletID = w["id"]
                break
        masterAccountWalletID = None
        for w2 in wallets:
            if w2["name"] == masterAccountWallet:
                masterAccountWalletID = w2["id"]
                break

        # if it doesn't exist, create the wallet and get its ID
        if not petitionWalletID:
            petitionWalletID = kcl.create_wallet(petitionWallet,
                                                 petitionWalletPassword)["id"]

        # get a handle for the wallet
        handle = kcl.init_wallet_handle(petitionWalletID,
                                        petitionWalletPassword)
        #### MASTER ACCOUNTS
        # if it doesn't exist, create the wallet and get its ID
        if not masterAccountWalletID:
            masterAccountWalletID = kcl.create_wallet(
                masterAccountWallet, masterAccountWalletPassword)["id"]
        # get a handle for the wallet
        handle2 = kcl.init_wallet_handle(masterAccountWalletID,
                                         masterAccountWalletPassword)
        # generate account with account and check if it's valid
        private_key_1, address_1 = account.generate_account()
        # generate master account with account and check if it's valid
        private_key_2, address_2 = account.generate_account()
        # import generated account into the wallet
        kcl.import_key(handle, private_key_1)
        kcl.import_key(handle2, private_key_2)

        # get the mnemonic for address_1
        mn = mnemonic.from_private_key(private_key_2)
        print("Mnemonic for the first account: " + mn + "\n")

        petition = Petition(name=form.name.data,
                            publicKey=address_1,
                            masterAccount=address_2,
                            yesCount=0,
                            startDate=form.startDate.data,
                            endDate=form.endDate.data)
        db.session.add(petition)
        db.session.commit()

        # Run bash script that automatically transfers microAlgos
        # from unencrypted-default-wallet to the desired Peition's
        # Master Account.
        # subprocess.call(["project/autoDispense.sh",str(address_2)])

        flash('Petition has been created!.', 'success')

    return render_template('petition/createPetition.html', form=form)
import json
from algosdk import account, mnemonic

acct = account.generate_account()
address1 = acct[1]
print("Account 1")
print(address1)
mnemonic1 = mnemonic.from_private_key(acct[0])

print("Account 2")
acct = account.generate_account()
address2 = acct[1]
print(address2)
mnemonic2 = mnemonic.from_private_key(acct[0])

print("Account 3")
acct = account.generate_account()
address3 = acct[1]
print(address3)
mnemonic3 = mnemonic.from_private_key(acct[0])
print("")
print(
    "Copy off accounts above and add TestNet Algo funds using the TestNet Dispenser at https://bank.testnet.algorand.network/"
)
print("copy off the following mnemonic code for use later")
print("")
print("mnemonic1 = \"{}\"".format(mnemonic1))
print("mnemonic2 = \"{}\"".format(mnemonic2))
print("mnemonic3 = \"{}\"".format(mnemonic3))
Ejemplo n.º 23
0
acl = algod.AlgodClient(params.algod_token, params.algod_address)

walletid = None
wallets = kcl.list_wallets()
# print("Wallet List:", wallets)
for arrayitem in wallets:
    if arrayitem.get("name") == "wallet1":
        walletid = arrayitem.get("id")
        break
print("Wallet ID:", walletid)
# getting wallethandle
wallethandle = kcl.init_wallet_handle(walletid, "testpassword")
print("Wallet Handle:", wallethandle)

# generate and print account 1
private_key1, address_1 = account.generate_account()
print("Private key:", private_key1)
print("Address:", address_1)

# generate and print account 2
private_key2, address_2 = account.generate_account()
print("Private key:", private_key2)
print("Address:", address_2)

# create a msig object
version = 1  # multisig version
threshold = 1  # how many signatures are necessary
msig = transaction.Multisig(version, threshold, [address_1, address_2])

# import msig object(multisig account) into kmd wallet
imported_multisig = kcl.import_multisig(wallethandle, msig)
Ejemplo n.º 24
0
# Example: creating a LogicSig transaction signed by a program that never approves the transfer.

import tokens
from algosdk import algod, account
from algosdk.future import transaction

program = b"\x01\x20\x01\x00\x22"  # int 0
lsig = transaction.LogicSig(program)
sender = lsig.address()
receiver = account.generate_account()

# create an algod client
acl = algod.AlgodClient(tokens.algod_token, tokens.algod_address)

# get suggested parameters
sp = acl.suggested_params()

# create a transaction
amount = 10000
txn = transaction.PaymentTxn(sender, sp, receiver, amount)

# note: transaction is signed by logic only (no delegation)
# that means sender address must match to program hash
lstx = transaction.LogicSigTransaction(txn, lsig)
assert lstx.verify()

# send them over network
acl.send_transaction(lstx)
Ejemplo n.º 25
0
def create_wallet():
    """ Create new Algorand wallet """
    private_key, address = account.generate_account()
    passphrase = mnemonic.from_private_key(private_key)
    return private_key, address, passphrase
Ejemplo n.º 26
0
# Example: sending assets

from algosdk import account
from algosdk.future import transaction

sender_private_key, sender_address = account.generate_account()

fee_per_byte = 10
first_valid_round = 1000
last_valid_round = 2000
genesis_hash = "SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI="
_, close_assets_to = account.generate_account()
_, receiver = account.generate_account()
amount = 100  # amount of assets to transfer

index = 1234  # identifying index of the asset

# create the asset transfer transaction
sp = transaction.SuggestedParams(fee_per_byte, first_valid_round,
                                 last_valid_round, genesis_hash)
txn = transaction.AssetTransferTxn(sender_address, sp, receiver, amount, index,
                                   close_assets_to)

# sign the transaction
signed_txn = txn.sign(sender_private_key)
Ejemplo n.º 27
0
# possibly replace MultisigTransaction method with Multisig
# https://github.com/algorand/py-algorand-sdk/blob/b079db660ae92d0dbf24dc04f28eb722711e426f/algosdk/transaction.py#L893

import params
from algosdk import account, transaction, algod, encoding

acl = algod.AlgodClient(params.algod_token, params.algod_address)

# generate three accounts
private_key_1, account_1 = account.generate_account()
private_key_2, account_2 = account.generate_account()
private_key_3, account_3 = account.generate_account()
print("Account 1:", account_1)
print("Account 2", account_2)
print("Account 3:", account_3)

# create a multisig account
version = 1  # multisig version
threshold = 2  # how many signatures are necessary
msig = transaction.Multisig(version, threshold, [account_1, account_2])
print("Multig Account: ", msig.address())
input(
    "Please go to: https://bank.testnet.algorand.network/ to fund your multisig account."
    + '\n' + "Press Enter to continue...")

# get suggested parameters
params = acl.suggested_params()
gen = params["genesisID"]
gh = params["genesishashb64"]
last_round = params["lastRound"]
fee = params["fee"]
Ejemplo n.º 28
0
def getting_started_example():
    # Using Rand Labs Developer API
    # see https://github.com/algorand/py-algorand-sdk/issues/169
    # Change algod_token and algod_address to connect to a different client
    # algod_token = "2f3203f21e738a1de6110eba6984f9d03e5a95d7a577b34616854064cf2c0e7b"
    # algod_address = "https://academy-algod.dev.aws.algodev.network/"
    # algod_address = "http://hackathon.algodev.network:9100"
    # algod_token = "ef920e2e7e002953f4b29a8af720efe8e4ecc75ff102b165e0472834b25832c1"

    algod_address = "http://hackathon.algodev.network:9100"
    algod_token = "ef920e2e7e002953f4b29a8af720efe8e4ecc75ff102b165e0472834b25832c1"
    # algod_address = "http://localhost:4001"
    # algod_token = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"

    algod_client = algod.AlgodClient(algod_token, algod_address)

    # Generate new account for this transaction
    secret_key, my_address = account.generate_account()

    print("My address: {}".format(my_address))
    print("My private key: {}".format(secret_key))
    # Check your balance. It should be 0 microAlgos

    account_info = algod_client.account_info(my_address)
    print("Account balance: {} microAlgos".format(account_info.get('amount')) +
          "\n")

    # Fund the created account
    print(
        'Fund the created account using testnet faucet: \n https://dispenser.testnet.aws.algodev.network/?account='
        + format(my_address))

    completed = ""
    while completed.lower() != 'yes':
        completed = input("Type 'yes' once you funded the account: ")

    print('Fund transfer in process...')
    # Wait for the faucet to transfer funds
    # time.sleep(10)

    print('Fund transferred!')
    # Check your balance. It should be 5000000 microAlgos
    account_info = algod_client.account_info(my_address)
    print("Account balance: {} microAlgos".format(account_info.get('amount')) +
          "\n")

    # build transaction
    print("Building transaction")
    params = algod_client.suggested_params()
    # comment out the next two (2) lines to use suggested fees
    # params.flat_fee = True
    # params.fee = 1000
    receiver = "HZ57J3K46JIJXILONBBZOHX6BKPXEM2VVXNRFSUED6DKFD5ZD24PMJ3MVA"
    note = "Hello World".encode()
    amount = 100000
    closeto = "HZ57J3K46JIJXILONBBZOHX6BKPXEM2VVXNRFSUED6DKFD5ZD24PMJ3MVA"
    # Fifth argument is a close_remainder_to parameter that creates a payment txn that sends all of the remaining funds to the specified address. If you want to learn more, go to: https://developer.algorand.org/docs/reference/transactions/#payment-transaction
    unsigned_txn = transaction.PaymentTxn(my_address, params, receiver, amount,
                                          closeto, note)

    # sign transaction
    print("Signing transaction")
    signed_txn = unsigned_txn.sign(secret_key)
    print("Sending transaction")
    txid = algod_client.send_transaction(signed_txn)
    print('Transaction Info:')
    print("Signed transaction with txID: {}".format(txid))

    # wait for confirmation
    try:
        print("Waiting for confirmation")
        confirmed_txn = transaction.wait_for_confirmation(
            algod_client, txid, 4)
    except Exception as err:
        print(err)
        return
    print(
        "txID: {}".format(txid), " confirmed in round: {}".format(
            confirmed_txn.get("confirmed-round", 0)))
    print("Transaction information: {}".format(
        json.dumps(confirmed_txn, indent=4)))
    print("Decoded note: {}".format(
        base64.b64decode(confirmed_txn["txn"]["txn"]["note"]).decode()))
    print("Starting Account balance: {} microAlgos".format(
        account_info.get('amount')))
    print("Amount transfered: {} microAlgos".format(amount))
    print("Fee: {} microAlgos".format(params.min_fee))
    closetoamt = account_info.get('amount') - (params.min_fee + amount)
    print("Close to Amount: {} microAlgos".format(closetoamt) + "\n")

    account_info = algod_client.account_info(my_address)
    print("Final Account balance: {} microAlgos".format(
        account_info.get('amount')) + "\n")
Ejemplo n.º 29
0
# Example: updating asset configuration

from algosdk import account
from algosdk.future import transaction

manager_private_key, manager_address = account.generate_account(
)  # this transaction must be sent from the manager's account
_, new_freeze = account.generate_account(
)  # account that can freeze other accounts for this asset
_, new_manager = account.generate_account(
)  # account able to update asset configuration
_, new_clawback = account.generate_account(
)  # account allowed to take this asset from any other account
_, new_reserve = account.generate_account(
)  # account that holds reserves for this asset

fee_per_byte = 10
first_valid_round = 1000
last_valid_round = 2000
genesis_hash = "SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI="

index = 1234  # identifying index of the asset

# create the asset config transaction
sp = transaction.SuggestedParams(fee_per_byte, first_valid_round,
                                 last_valid_round, genesis_hash)
txn = transaction.AssetConfigTxn(manager_address,
                                 sp,
                                 manager=new_manager,
                                 reserve=new_reserve,
                                 freeze=new_freeze,
Ejemplo n.º 30
0
def generate_new_account():
    private_key, address = account.generate_account()
    print("Created new account: ", address)
    print("Generated mnemonic: \"{}\"".format(
        mnemonic.from_private_key(private_key)))
    return address