From b953f78c2087eae723070b821ffc86ca5164ab67 Mon Sep 17 00:00:00 2001 From: Joe Chen Date: Thu, 28 Nov 2024 15:46:49 +0800 Subject: [PATCH 1/4] add a multi-send script for rgas --- scripts/multi-sender/addresses.txt | 1 + scripts/multi-sender/main.go | 57 ++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 scripts/multi-sender/addresses.txt create mode 100644 scripts/multi-sender/main.go diff --git a/scripts/multi-sender/addresses.txt b/scripts/multi-sender/addresses.txt new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/scripts/multi-sender/addresses.txt @@ -0,0 +1 @@ + diff --git a/scripts/multi-sender/main.go b/scripts/multi-sender/main.go new file mode 100644 index 0000000000..75d5fa4d5b --- /dev/null +++ b/scripts/multi-sender/main.go @@ -0,0 +1,57 @@ +package main + +import ( + "bufio" + "fmt" + "io" + "log" + "os" + "os/exec" +) + +func main() { + change_env := exec.Command("rooch", "env", "switch", "--alias", "test") + out, err := change_env.CombinedOutput() + if err != nil { + fmt.Printf("combined out:\n%s\n", string(out)) + log.Fatal("change_env.Run() failed with %s\n", err) + } + fmt.Printf("combined out\n%s\n", string(out)) + + read_file("addresses.txt") +} + +func read_file(path string) error { + f, err := os.OpenFile(path, os.O_RDONLY, 0666) + if err != nil { + return err + } + + defer f.Close() + + reader := bufio.NewReader(f) + + var results []string + for { + line, _, err := reader.ReadLine() + if err == io.EOF { + break + } + // rooch account transfer --to rooch1z6jp5k2vj2hs75zdqe5rhgdaj4w3hjnm693ks6xaxxdr78vvxreqwrrvpt --coin-type 0x3::gas_coin::RGas --amount 1 + send := exec.Command("rooch", "account", "transfer", "--coin-type", "0x3::gas_coin::RGas", "--amount", "1", "--to", string(line)) + _, err = send.CombinedOutput() + if err != nil { + // fmt.Printf("combined out:\n%s\n", string(out)) + fmt.Println(string(line), "=> ok") + // log.Fatal("send.Run() failed with %s\n", err) + log.Fatal("send failed\n") + } + // fmt.Printf("combined out\n%s\n", string(out)) + + + // fmt.Println(string(line)) + results = append(results, string(line)) + } + fmt.Printf("Read results: %v\n", results) + return nil +} From 29650728c0ff767ec2f0644d499ec950c4363b43 Mon Sep 17 00:00:00 2001 From: Joe Chen Date: Thu, 28 Nov 2024 16:45:38 +0800 Subject: [PATCH 2/4] update --- scripts/multi-sender/main.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/multi-sender/main.go b/scripts/multi-sender/main.go index 75d5fa4d5b..1349130723 100644 --- a/scripts/multi-sender/main.go +++ b/scripts/multi-sender/main.go @@ -10,7 +10,7 @@ import ( ) func main() { - change_env := exec.Command("rooch", "env", "switch", "--alias", "test") + change_env := exec.Command("rooch", "env", "switch", "--alias", "main") out, err := change_env.CombinedOutput() if err != nil { fmt.Printf("combined out:\n%s\n", string(out)) @@ -46,6 +46,7 @@ func read_file(path string) error { // log.Fatal("send.Run() failed with %s\n", err) log.Fatal("send failed\n") } + fmt.Println(string(line), "=> ok") // fmt.Printf("combined out\n%s\n", string(out)) From 6f4004ff75fc5255a78b25a4d68def3a26a0c5d9 Mon Sep 17 00:00:00 2001 From: Joe Chen Date: Thu, 28 Nov 2024 18:35:04 +0800 Subject: [PATCH 3/4] update --- scripts/multi-sender/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/multi-sender/main.go b/scripts/multi-sender/main.go index 1349130723..9aee709db7 100644 --- a/scripts/multi-sender/main.go +++ b/scripts/multi-sender/main.go @@ -38,7 +38,7 @@ func read_file(path string) error { break } // rooch account transfer --to rooch1z6jp5k2vj2hs75zdqe5rhgdaj4w3hjnm693ks6xaxxdr78vvxreqwrrvpt --coin-type 0x3::gas_coin::RGas --amount 1 - send := exec.Command("rooch", "account", "transfer", "--coin-type", "0x3::gas_coin::RGas", "--amount", "1", "--to", string(line)) + send := exec.Command("rooch", "account", "transfer", "--coin-type", "0x3::gas_coin::RGas", "--amount", "10000000000", "--to", string(line)) _, err = send.CombinedOutput() if err != nil { // fmt.Printf("combined out:\n%s\n", string(out)) From 0f886a54c100fa388b14e130a7b3a488abbf9f19 Mon Sep 17 00:00:00 2001 From: Joe Chen Date: Thu, 28 Nov 2024 18:50:05 +0800 Subject: [PATCH 4/4] update --- scripts/multi-sender/addresses.txt | 1 - scripts/multi-sender/main.go | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/scripts/multi-sender/addresses.txt b/scripts/multi-sender/addresses.txt index 8b13789179..e69de29bb2 100644 --- a/scripts/multi-sender/addresses.txt +++ b/scripts/multi-sender/addresses.txt @@ -1 +0,0 @@ - diff --git a/scripts/multi-sender/main.go b/scripts/multi-sender/main.go index 9aee709db7..6d1f8359df 100644 --- a/scripts/multi-sender/main.go +++ b/scripts/multi-sender/main.go @@ -10,7 +10,9 @@ import ( ) func main() { - change_env := exec.Command("rooch", "env", "switch", "--alias", "main") + // Change the network + const NETWORK = "test" + change_env := exec.Command("rooch", "env", "switch", "--alias", NETWORK) out, err := change_env.CombinedOutput() if err != nil { fmt.Printf("combined out:\n%s\n", string(out)) @@ -38,6 +40,7 @@ func read_file(path string) error { break } // rooch account transfer --to rooch1z6jp5k2vj2hs75zdqe5rhgdaj4w3hjnm693ks6xaxxdr78vvxreqwrrvpt --coin-type 0x3::gas_coin::RGas --amount 1 + // Transfer 100 Rgas, 1 RGas = 100000000 send := exec.Command("rooch", "account", "transfer", "--coin-type", "0x3::gas_coin::RGas", "--amount", "10000000000", "--to", string(line)) _, err = send.CombinedOutput() if err != nil { @@ -48,9 +51,6 @@ func read_file(path string) error { } fmt.Println(string(line), "=> ok") // fmt.Printf("combined out\n%s\n", string(out)) - - - // fmt.Println(string(line)) results = append(results, string(line)) } fmt.Printf("Read results: %v\n", results)