-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_offers.ps1
53 lines (47 loc) · 1.9 KB
/
make_offers.ps1
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
#
# Create offer files for NFTs. Assume all are priced at same amount. Filename will be the NFT ID with an extension of ".offer"
#
# NOTE: Using the RPC to create the offers requires us to have the Launcher ID for the NFT, not the NFT ID. The input file should contain a list of Launcher IDs.
#
$blockchains = @("chia","aba")
Write-Host "--Blockchain Selection--"
$outcount = 1
$loopcount = 1
foreach ($chain in $blockchains) {
#if ($loopcount % 2 -eq 1) {
# $option = [string]$outcount + ": " + [string]$chain + " - "
#} else {
#
#}
$option = "$loopcount. " + [string]$chain
Write-Host $option
$outcount++
$loopcount++
}
$choice = Read-Host "Choose blockchain"
$choice = [int]$choice - 1
$blockchain = $blockchains[$choice]
Write-Host "Selected blockchain: $blockchain"
Write-Host ""
$fee = Read-Host "Enter fee amount in mojos"
$price = Read-Host "Enter price amount in mojos"
$subfolderPath = Read-Host "Enter folder for offer files"
if (-not (Test-Path -Path $subfolderPath -PathType Container)) {
New-Item -Path $subfolderPath -ItemType Directory | Out-Null
Write-Host "Folder created: $subfolderPath"
} else {
Write-Host "Folder already exists: $subfolderPath"
}
$filename = Read-Host "Enter filename with Launcher Coin IDs for offers"
$total_lines = (Get-Content -Path $filename | Where-Object { $_ -ne "" }).Count
$fileContent = Get-Content -Path $filename
foreach ($line in $fileContent) {
Write-Host "Processing: $line"
Set-Content -Path "tempfile.json" -Value "{""offer"":{""1"":$price,""$line"":-1},""fee"":$fee,""driver_dict"":{},""validate_only"":false}"
$jsonResponse = Invoke-Expression "$blockchain rpc wallet create_offer_for_ids -j tempfile.json"
$jsonObject = $jsonResponse | ConvertFrom-Json
$offer = $jsonObject.offer
Set-Content -Path "$subfolderPath\$line.offer" -Value $offer
}
Remove-Item -Path "tempfile.json"
Write-Host "Done."