示例#1
0
def mint_official_nft(swarm_hash: str, is_public: bool, username: str, title: str, number: int,
                      asset_symbol: str = 'MYPIC', asset_name: str = 'MyPic NFT', website_url: str = 'http://mypic.io'):
    params = algod_client.suggested_params()
    params.fee = 1000
    params.flat_fee = True

    data_set = {"is_public": f'{is_public}', 'username': username, 'title': title, 'number': f'{number}'}

    tx_note_json_str = json.dumps(data_set)
    tx_note_bytes = tx_note_json_str.encode("utf-8")
    swarm_hash_bytes = unhexlify(swarm_hash)
    txn = AssetConfigTxn(sender=accounts[1]['pk'],
                         sp=params,
                         total=1,
                         decimals=0,
                         unit_name=asset_symbol,
                         asset_name=asset_name,
                         strict_empty_address_check=False,
                         default_frozen=False,
                         metadata_hash=swarm_hash_bytes,
                         note=tx_note_bytes,
                         manager=accounts[1]['pk'],
                         reserve=accounts[1]['pk'],
                         freeze="",
                         clawback=accounts[1]['pk'],
                         url=website_url)

    stxn = txn.sign(accounts[1]['sk'])
    tx_id = algod_client.send_transaction(stxn)
    wait_for_confirmation(tx_id)
    ptx = algod_client.pending_transaction_info(tx_id)
    asset_id = ptx["asset-index"]
    return asset_id
示例#2
0
文件: temp_sm.py 项目: kilagg/mypic
def transfer_algo_to_user(receiver, micro_algo_amount):
    mypic_private_key = get_private_key_from_mnemonic(word_mnemonic)
    params = algod_client.suggested_params()
    txn = PaymentTxn(ADDRESS_ALGO_OURSELF, params, receiver, micro_algo_amount)
    stxn = txn.sign(mypic_private_key)
    tx_id = algod_client.send_transaction(stxn)
    return tx_id
示例#3
0
def fund_smart_contract(smartcontract_address):
    seller_private_key = get_private_key_from_mnemonic(WORD_MNEMONIC)
    params = algod_client.suggested_params()
    params.fee = 1000
    txn = PaymentTxn(ADDRESS_ALGO_OURSELF, params, smartcontract_address, 120000)
    stxn = txn.sign(seller_private_key)
    tx_id = algod_client.send_transaction(stxn)
    return tx_id
示例#4
0
文件: temp_sm.py 项目: kilagg/mypic
def transfer_nft_to_user(asset_id, address):
    mypic_private_key = get_private_key_from_mnemonic(word_mnemonic)
    params = algod_client.suggested_params()
    params.fee = 1000
    params.flat_fee = True
    txn = AssetTransferTxn(sender=ADDRESS_ALGO_OURSELF,
                           sp=params,
                           receiver=address,
                           amt=1,
                           index=asset_id)
    stxn = txn.sign(mypic_private_key)
    tx_id = algod_client.send_transaction(stxn)
    return tx_id
示例#5
0
文件: temp_sm.py 项目: kilagg/mypic
def opt_in_asset(asset_id):
    mn = 'tattoo market oven bench betray double tuna box sand lottery champion spend melt virus motor label bacon wine rescue custom cannon pen merry absorb endorse'
    public_key = get_public_key_from_mnemonic(mn)
    print(public_key)
    private_key = get_private_key_from_mnemonic(mn)
    params = algod_client.suggested_params()
    params.fee = 1000
    params.flat_fee = True
    txn = AssetTransferTxn(sender=ADDRESS_ALGO_OURSELF,
                           sp=params,
                           receiver=public_key,
                           amt=0,
                           index=asset_id)
    stxn = txn.sign(private_key)
    tx_id = algod_client.send_transaction(stxn)
    wait_for_confirmation(tx_id)
    print("Asset ", asset_id, " opted in for ACCOUNT ", public_key)