Skip to content

Commit 0ff2dae

Browse files
committed
Add Minswap example
1 parent 48ee125 commit 0ff2dae

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

Blockfrost/helper_functions.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,8 @@ def get_api_token():
3131
def unix_to_time(df):
3232
df['time'] = df['time'].astype(int)
3333
df['time'] = pd.to_datetime(df['block_time'], unit='s')
34-
return df
34+
return df
35+
36+
def asciitoken_name(asset_name):
37+
ascii_name = bytearray.fromhex(asset_name).decode()
38+
return ascii_name

Blockfrost/minswap_swap.py

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import pandas as pd
2+
from helper_functions import read_csv, write_csv, get_api_token, asciitoken_name
3+
from token_info import policy_id, asset_name
4+
5+
# Load Blockfrost API key
6+
api = get_api_token()
7+
8+
# Token info
9+
policy_id = policy_id
10+
asset_name = asset_name
11+
token_name = asciitoken_name(asset_name)
12+
13+
# Minswap swap address
14+
minswap_addy = "addr1zxn9efv2f6w82hagxqtn62ju4m293tqvw0uhmdl64ch8uw6j2c79gy9l76sdg0xwhd7r0c0kna0tycz4y5s6mlenh8pq6s3z70"
15+
16+
17+
def swap_info(swap_addy, policy_id, asset_name, max_page):
18+
df = pd.DataFrame()
19+
while True:
20+
data = api.address_utxos_asset(
21+
address=swap_addy, asset=policy_id + asset_name, return_type="pandas")
22+
df = pd.concat([data, df])
23+
return df
24+
25+
swap_df = swap_info(minswap_addy, policy_id, asset_name, 5)
26+
print(swap_df)
27+
28+
write_csv(swap_df, token_name + "_swap_info.csv")

0 commit comments

Comments
 (0)