-
Notifications
You must be signed in to change notification settings - Fork 7
/
main.go
48 lines (39 loc) · 1.12 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
48
package main
import (
"context"
"encoding/json"
"fmt"
"log"
"os"
"github.com/1inch/1inch-sdk-go/constants"
"github.com/1inch/1inch-sdk-go/sdk-clients/txbroadcast"
)
var (
devPortalToken = os.Getenv("DEV_PORTAL_TOKEN")
)
func main() {
config, err := txbroadcast.NewConfiguration(txbroadcast.ConfigurationParams{
ChainId: constants.EthereumChainId,
ApiUrl: "https://api.1inch.dev",
ApiKey: devPortalToken,
})
if err != nil {
log.Fatalf("failed to create configuration: %v", err)
}
client, err := txbroadcast.NewClient(config)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
ctx := context.Background()
broadcastPublicResponse, err := client.BroadcastPublicTransaction(ctx, txbroadcast.BroadcastRequest{
RawTransaction: "<YOUR RAW TX here>",
})
if err != nil {
log.Fatalf("failed to BroadcastPublicTransaction: %v", err)
}
broadcastPublicResponseIndented, err := json.MarshalIndent(broadcastPublicResponse, "", " ")
if err != nil {
log.Fatalf("failed to marshal broadcastPublicResponse: %v", err)
}
fmt.Printf("BroadcastPublicTransaction: %s\n", broadcastPublicResponseIndented)
}