Skip to content

Instantly share code, notes, and snippets.

@raza-basit
Created September 7, 2017 09:52
Show Gist options
  • Save raza-basit/6d623dd05f748ded30a6538875d39f1c to your computer and use it in GitHub Desktop.
Save raza-basit/6d623dd05f748ded30a6538875d39f1c to your computer and use it in GitHub Desktop.
Get List of accounts in ethereum node using golang
var callOptions = []byte(`{"jsonrpc": "2.0", "method":"personal_listAccounts", "params":[], "id":1}`)
req, err := http.NewRequest("post", "http://localhost:8545/", bytes.NewBuffer(callOptions))
if err != nil {
log.Fatal(err)
}
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
log.Println(string(body))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment