-
Notifications
You must be signed in to change notification settings - Fork 1
/
offline_mint_tokens.py
executable file
·37 lines (30 loc) · 1.47 KB
/
offline_mint_tokens.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python3
# Copyright (c) DeFi Blockchain Developers
'''
Following script requires these Python packages to be installed with pip3
or your package management software.
base58, ecdsa, hashlib and python_bitcoinlib
'''
# defi directory must be included
from defi.interface import *
from defi.transactions import make_signed_transaction
# Help info
if len(sys.argv) != 5:
print_and_exit('\nUsage: offline_mint_tokens.py tokenID amount "private key" "input"\n\n'
'tokenID (number): token identifier\n\n'
'amount (number): number of tokens to create\n\n'
'private key (string): private key to sign transaction. Input MUST be from this key and\n'
'be the owner of the token we are minting tokens for.\n\n'
'input (string): UTXO for the collateral address, amount to spend in UTXO, change sent\n'
'to private key address, 0.0001 fee. Optional P2PKH or P2SH-P2WPKH to indicate input type,\n'
'the default type is P2SH-P2WPKH\n'
'input example: \'[{"txid":"TXID","vout":0,"amount":"0.00000000","type":"P2SH-P2WPKH"}]\'\n')
# Get args from user
tokenID = user_token_id()
amount = user_amount()
privateKey = user_private_key()
txid, vout, inputAmount, has_segwit = user_utxo()
# Create mint tokens payload
outputTokenPayload = "146a12446654784d01" + tokenID + amount
# Create and print signed raw transaction
print("\nSigned TX:", make_signed_transaction(privateKey, txid, vout, inputAmount, outputTokenPayload, has_segwit))