package main
import (
"context"
"math/big"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
)
func main() {
ctx := context.Background()
client, err := ethclient.DialContext(ctx, "https://public-evm-rpc.c8ntinuum.com")
if err != nil {
panic(err)
}
height, err := client.BlockNumber(ctx)
if err != nil {
panic(err)
}
block, err := client.BlockByNumber(ctx, new(big.Int).SetUint64(height))
if err != nil {
panic(err)
}
txHash := common.HexToHash("0x...")
tx, pending, err := client.TransactionByHash(ctx, txHash)
if err != nil {
panic(err)
}
receipt, err := client.TransactionReceipt(ctx, txHash)
if err != nil {
panic(err)
}
fromBlock := uint64(0)
if height > 500 {
fromBlock = height - 500
}
query := ethereum.FilterQuery{
FromBlock: new(big.Int).SetUint64(fromBlock),
ToBlock: new(big.Int).SetUint64(height),
Addresses: []common.Address{common.HexToAddress("0xc8Fb80fCc03f699C70ff0CC08C09106288888888")},
Topics: [][]common.Hash{{
common.HexToHash("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"),
}},
}
logs, err := client.FilterLogs(ctx, query)
if err != nil {
panic(err)
}
// Broadcast a signed transaction returned by your offline signer:
// var signed *types.Transaction
// err = client.SendTransaction(ctx, signed)
_, _, _, _ = block, tx, pending, receipt
_ = logs
}