You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

test.go 996 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package blockchain
  2. import (
  3. "fmt"
  4. "io/ioutil"
  5. "net/http"
  6. "strings"
  7. )
  8. func main() {
  9. url := "http://localhost:2006/contract/invoke"
  10. method := "POST"
  11. payload := strings.NewReader(`{` + " " + ` "contractAddress" : "0xc860ab27901b3c2b810165a6096c64d88763617f",` + " " + ` "functionName" : "storeEvidence",` + " " + ` "args" : ["3","touteng"],` + " " + ` "memberName" :"pcm",` + " " + ` "type": "2"` + " " + ` }`)
  12. client := &http.Client{}
  13. req, err := http.NewRequest(method, url, payload)
  14. if err != nil {
  15. fmt.Println(err)
  16. return
  17. }
  18. req.Header.Add("User-Agent", "Apifox/1.0.0 (https://apifox.com)")
  19. req.Header.Add("Content-Type", "application/json")
  20. req.Header.Add("Accept", "*/*")
  21. req.Header.Add("Host", "localhost:2006")
  22. req.Header.Add("Connection", "keep-alive")
  23. res, err := client.Do(req)
  24. if err != nil {
  25. fmt.Println(err)
  26. return
  27. }
  28. defer res.Body.Close()
  29. body, err := ioutil.ReadAll(res.Body)
  30. if err != nil {
  31. fmt.Println(err)
  32. return
  33. }
  34. fmt.Println(string(body))
  35. }