Skip to content

Instantly share code, notes, and snippets.

@MattKetmo
Last active July 8, 2022 07:27
Show Gist options
  • Save MattKetmo/d542d3d25745c0b6e1f27fc5401cfe9f to your computer and use it in GitHub Desktop.
Save MattKetmo/d542d3d25745c0b6e1f27fc5401cfe9f to your computer and use it in GitHub Desktop.
eth goerli coding ex
package main
import (
"fmt"
"os"
)
func main() {
address := "0xbad1568bf8d55f5f808edec0cd7394ebd8d51d0e"
fromBlock := 6974800
toBlock := 6974900
result := searchBlock(address, fromBlock, toBlock)
if result < fromBlock || result > toBlock {
fmt.Printf("error: result must be between %d and %d (actual: %d)\n", fromBlock, toBlock, result)
os.Exit(1)
}
fmt.Printf("result = %d\n", result)
}
// Find the block where the balance of the given address changed.
func searchBlock(address string, fromBlock, toBlock int) int {
// TODO
return 0
}
// Return the balance of an address at a given block.
//
// Example with curl:
// curl -XPOST -H "Content-Type: application/json" https://goerli.infura.io/v3/1958344898c54b909598f1d0b8457805 \
// -d '{"jsonrpc":"2.0","method":"eth_getBalance","params":["0xbad1568bf8d55f5f808edec0cd7394ebd8d51d0e", "0x6a6ec1"],"id":1}'
func getBalance(address string, blockId int) string {
// TODO
return "0"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment