-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTUM_mint.py
62 lines (33 loc) · 1.34 KB
/
TUM_mint.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from xrpl.asyncio.clients import AsyncWebsocketClient
from xrpl.transaction import safe_sign_and_submit_transaction, submit_transaction
from xrpl.models.transactions import NFTokenMint, NFTokenCreateOffer, NFTokenAcceptOffer
#from xrpl.utils import str_to_hex, hex_to_str
import xrpl.wallet
from xrpl.utils.str_conversions import str_to_hex, hex_to_str
import asyncio
import nest_asyncio
nest_asyncio.apply()
content = "HELLO"
async def mint(ipfs):
# hex the content string
hex_ipfs = str_to_hex(f"{ipfs}")
# connect to websocket of testnet
async with AsyncWebsocketClient("wss://s.altnet.rippletest.net:51233") as client:
## create address and fund from faucet
new_wallet = xrpl.wallet.generate_faucet_wallet(client, debug=True)
print("generated address and funded successful")
## create mint nft transaction
trx = NFTokenMint(
account=new_wallet.classic_address,
nftoken_taxon=1,
transfer_fee = 5000,
uri = f"{hex_ipfs}",
flags = 0x00000008
)
## sign the transaction and submit
submit = safe_sign_and_submit_transaction(trx,new_wallet,client)
print(submit.result)
def main():
asyncio.run(mint(content))
if __name__ == "__main__":
main()