geek96
9/7/2017 - 9:53 AM

Creating ethereum account using golang

Creating ethereum account using golang

var callOptions = []byte(`{"jsonrpc": "2.0", "method":"personal_newAccount", "params":["yourpassword"], "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))