Skip to content

Instantly share code, notes, and snippets.

@ezynda3
Created January 2, 2018 13:58
Show Gist options
  • Save ezynda3/551155e9b6447224d9ff2431c1f57488 to your computer and use it in GitHub Desktop.
Save ezynda3/551155e9b6447224d9ff2431c1f57488 to your computer and use it in GitHub Desktop.
Golang Ethereum Connection Example
package main
import (
"context"
"fmt"
"log"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
)
func main() {
conn, err := ethclient.Dial("https://mainnet.infura.io")
if err != nil {
log.Fatal("Whoops something went wrong!", err)
}
ctx := context.Background()
tx, pending, _ := conn.TransactionByHash(ctx, common.HexToHash("0x30999361906753dbf60f39b32d3c8fadeb07d2c0f1188a32ba1849daac0385a8"))
if !pending {
fmt.Println(tx)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment