Skip to content

Instantly share code, notes, and snippets.

@jduffey
Last active August 7, 2021 18:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jduffey/5fca15cfb3c35b887c8f475e9ee57a6f to your computer and use it in GitHub Desktop.
Save jduffey/5fca15cfb3c35b887c8f475e9ee57a6f to your computer and use it in GitHub Desktop.
Script for creating pooled Chia plots; tested with Chia v1.2.3
<#
This script has been tested with Chia version 1.2.3
Chia must be running and synced in order to execute this script,
otherwise the "chia.exe plotnft show" command will fail.
#>
<#
Begin user-defined values.
#>
$PlotterDrive = "E"
$QueueNumber = "1"
$PlotDestination = "D:\Staging"
$MemoryBuffer = 3390
$ThreadsAllocated = 4
$SecondsToSleep = 3600 * 0
<#
End user-defined values.
#>
$ChiaDaemonPath = "$env:USERPROFILE\AppData\Local\chia-blockchain\app-*\resources\app.asar.unpacked\daemon"
Write-Output "Chia Daemon Path: $ChiaDaemonPath"
try {
& $ChiaDaemonPath\chia.exe > $null
} catch {
Write-Output "`nERROR! The following error occurred when attempting to call Chia:`n"
Write-Output $_
Write-Output "`nHINT: Is Chia properly installed on this machine?"
exit
}
$ChiaVersion = & $ChiaDaemonPath\chia.exe version
Write-Output "Chia version: $ChiaVersion"
$KeysInfo = & $ChiaDaemonPath\chia.exe keys show
foreach ($Line in $KeysInfo) {
if ($Line.StartsWith("Farmer public key")) {
$FarmerPublicKeyLineSplit = $Line -Split ":"
$FarmerPublicKey = $FarmerPublicKeyLineSplit[1].Trim()
Write-Output "Farmer public key: $FarmerPublicKey"
}
}
$PlotNftInfo = & $ChiaDaemonPath\chia.exe plotnft show
foreach ($Line in $PlotNftInfo) {
if ($Line.StartsWith("Pool contract address")) {
$PoolContractAddressLineSplit = $Line -Split ":"
$PoolContractAddress = $PoolContractAddressLineSplit[1].Trim()
Write-Output "Pool contract address: $PoolContractAddress"
}
}
if([string]::IsNullOrEmpty($FarmerPublicKey)) {
Write-Output "`nERROR! Cannot find the farmer key which is required to begin plotting.`n"
Write-Output "HINT: Have you created or imported a private seed phrase yet?"
exit
}
if([string]::IsNullOrEmpty($PoolContractAddress)) {
Write-Output "`nERROR! Cannot find pool contract address information.`n"
Write-Output "HINT: Have you created (or synced with?) a pool NFT yet?"
exit
}
<#
k-size, number of plots, and buckets values should be changed only by advanced users!
#>
$KSize = 33
$NumberOfPlots = 1
$Buckets = 128
$TempPath = "${PlotterDrive}:\ChiaPlotTemp\$QueueNumber"
Get-Date
Write-Output "Sleeping for $SecondsToSleep seconds before beginning..."
Start-Sleep -Seconds $SecondsToSleep
<#
Plot creation command is below, set to run in an infinite loop.
#>
while ($true) {
Get-Date
Get-ChildItem -Path $TempPath -Include *.* -File -Recurse | ForEach-Object { $_.Delete()}
Write-Output "`nBeginning plot creation with the following parameters:`n"
Write-Output "k-size: $KSize"
Write-Output "Number of plots: $NumberOfPlots"
Write-Output "Memory buffer (MiB): $MemoryBuffer"
Write-Output "Farmer public key: $FarmerPublicKey"
Write-Output "Pool contract address: $PoolContractAddress"
Write-Output "Temp plot path: $TempPath"
Write-Output "Plot destination path: $PlotDestination"
Write-Output "Thread allocated: $ThreadsAllocated"
Write-Output "Buckets: $Buckets"
Write-Output "`nChia plot creation command output below...`n"
& $ChiaDaemonPath\chia.exe plots create `
-f $FarmerPublicKey `
-c $PoolContractAddress `
-t $TempPath `
-d $PlotDestination `
-k $KSize `
-n $NumberOfPlots `
-b $MemoryBuffer `
-r $ThreadsAllocated `
-u $Buckets
Write-Output "`nPooling Plot created and copied to $PlotDestination.`n"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment