-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
47 lines (38 loc) · 1.11 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main
import (
"fmt"
"log"
"net/http"
config "userop-builder/config"
"userop-builder/userop"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
)
func hello(w http.ResponseWriter, req *http.Request) {
ownerAddress := common.HexToAddress( "0xAcC0FD2E9e3514DCDBcd3Ebf6144c08a44962c03")
client, err := ethclient.Dial(config.ProviderUrl)
if err != nil {
log.Fatal(err)
}
uob :=userop.NewUserOpBuilder(ownerAddress,client)
//address := uob.GetCounterFactualAddress()
uop := uob.CreateUnsignedUserOp()
jsonData,err := uop.MarshalJSON()
if err != nil {
log.Fatal(err)
}
w.Header().Set("Content-Type", "application/json")
w.Write(jsonData)
}
func headers(w http.ResponseWriter, req *http.Request) {
for name, headers := range req.Header {
for _, h := range headers {
fmt.Fprintf(w, "%v: %v\n", name, h)
}
}
}
func main() {
http.HandleFunc("/hello", hello)
http.HandleFunc("/headers", headers)
http.ListenAndServe(":8090", nil)
}