-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetpolicy.ps1
49 lines (40 loc) · 1.33 KB
/
getpolicy.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
#params
[bool] $test = 1
$timeToMint = 3200 # 1 hour
if($test){
$network="--testnet-magic", "1097911063"
$addr="addr_test1xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
$logfile="C:\Users\user\AppData\Roaming\Daedalus Testnet\Logs\pub\cardano-wallet.log"
} else {
$network="--mainnet"
$addr="addr1xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
$logfile="C:\Users\user\AppData\Roaming\Daedalus Mainnet\Logs\pub\cardano-wallet.log"
}
#init
cd C:\Users\user\Documents\cardano
Select-String '^.*--node-socket (\S+).*$' $logfile |
Select-Object -Last 1 |
ForEach-Object { $socket = $_.Matches[0].Groups[1].Value } #get last occurence in file
$env:CARDANO_NODE_SOCKET_PATH = $socket
cd policy
cardano-cli address key-gen --verification-key-file policy.vkey --signing-key-file policy.skey
$hash = cardano-cli address key-hash --payment-verification-key-file policy.vkey
"{
`"type`": `"all`",
`"scripts`": [
{
`"keyHash`": `"$hash`",
`"type`": `"sig`"
},
{
`"type`": `"before`",
`"slot`": $before
}
]
}" | Out-File -FilePath policy.script
[string]::Join( "`n", (gc policy.script)) | sc policy.script
$tip = cardano-cli query tip $network
$slot = ($tip | Out-String | ConvertFrom-Json).slot
$before = 41480089
$policyId = cardano-cli transaction policyid --script-file policy.script
Write-Host($policyId > policyid.txt)