跳转到主要内容
Go-Ethereum 是 Ethereum 官方的 Go 实现,用于与区块链交互。Go-Ethereum,简称 geth,是最流行的 Ethereum 客户端。在使用 Golang 开发应用时,它提供了读取和写入区块链所需的一切。使用网关端点将其连接到 Node RPC,并参见 JSON-RPC 参考 以了解受支持的方法。
client.go
package main

import (
    "fmt"
    "log"
    "github.com/ethereum/go-ethereum/ethclient"
)

func main() {
    client, err := ethclient.Dial("https://mainnet.gateway.tenderly.co/<TENDERLY_NODE_ACCESS_KEY_MAINNET>")
    if err != nil {
        log.Fatal(err)
    }

    fmt.Println("we have a connection")
    _ = client // we'll use this in the upcoming sections
}