Last active
June 2, 2019 17:00
-
-
Save toschdev/41f57629bf519d6de27f8b424e97519d to your computer and use it in GitHub Desktop.
Create Ardor Bundler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Author: Tobias Schwarz March 2019 | |
package main | |
import ( | |
"fmt" | |
"gopkg.in/resty.v1" | |
"os" | |
) | |
const ( | |
ARDORURL = "http://localhost:26876/nxt" //http://localhost:27876/nxt for mainnet | |
CHAIN = "2" //Ignis community chain | |
SECRETPHRASE = "<yoursecretpassphrase>" //Twelve word secret passphrase from NRS | |
MINRATENQTPERFXT = "100000000" //Minimum rate to pay, multiplier of Ardor fees | |
TOTALFEESLIMITFQT = "20000000000" //Limit of Ardor to spend | |
OVERPAY = "0" //Multiplier for overpaying transactions | |
FEECALCULATOR = "MIN_FEE" //Paying minimum Ardor fees | |
) | |
func main() { | |
if len(os.Args) < 2 { | |
fmt.Println("Start script with either ./bundler start or ./bundler stop") | |
return | |
} | |
startOrStop := os.Args[1] | |
switch startOrStop { | |
case "start": | |
fmt.Println(startBundler()) | |
case "stop": | |
fmt.Println(stopBundler()) | |
default: | |
fmt.Println("Start script with either ./bundler start or ./bundler stop") | |
} | |
} | |
func startBundler() (string) { | |
resp, error_response := resty.R(). | |
SetHeader("Content-Type", "application/x-www-form-urlencoded"). | |
SetQueryParam("requestType", "startBundler"). | |
SetQueryParam("chain", CHAIN). | |
SetQueryParam("secretPhrase", SECRETPHRASE). | |
SetQueryParam("minRateNQTPerFXT", MINRATENQTPERFXT). | |
SetQueryParam("totalFeesLimitFQT", TOTALFEESLIMITFQT). | |
SetQueryParam("overpayFQTPerFXT", OVERPAY). | |
SetQueryParam("feeCalculatorName", FEECALCULATOR). | |
// SetQueryParam("filter", ""). // API filters - advanced | |
Post(ARDORURL) | |
fmt.Println(error_response) | |
return resp.String() | |
} | |
func stopBundler() (string) { | |
resp, error_response := resty.R(). | |
SetHeader("Content-Type", "application/x-www-form-urlencoded"). | |
SetQueryParam("requestType", "stopBundler"). | |
SetQueryParam("chain", CHAIN). | |
SetQueryParam("secretPhrase", SECRETPHRASE). | |
Post(ARDORURL) | |
fmt.Println(error_response) | |
return resp.String() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment