Skip to content

Instantly share code, notes, and snippets.

@veox
Created October 1, 2019 16:44
Show Gist options
  • Select an option

  • Save veox/b458636b7c75eef941463d4146c11be9 to your computer and use it in GitHub Desktop.

Select an option

Save veox/b458636b7c75eef941463d4146c11be9 to your computer and use it in GitHub Desktop.

Revisions

  1. veox created this gist Oct 1, 2019.
    32 changes: 32 additions & 0 deletions RawBlock.go
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    // https://gist.github.com/SomniaStellarum/1753b2b469864e7ce8350cae2a4e2ab2
    package main

    import (
    "bytes"
    "context"
    "fmt"
    //"github.com/ethereum/go-ethereum/common/hexutil"
    "github.com/ethereum/go-ethereum/ethclient"
    //"github.com/ethereum/go-ethereum/rlp"
    "math/big"
    //"reflect"
    )

    var server = "http://localhost:8545"

    //var blockHash = "0xac8e95f7483f7131261bcc0a70873f8236c27444c940defc677f74f281220193"

    func main() {
    cl, _ := ethclient.Dial(server)
    ctx := context.Background()
    blk, _ := cl.BlockByNumber(ctx, big.NewInt(0))

    fmt.Printf("%x\n", blk.Hash())

    buf := new(bytes.Buffer)
    blk.EncodeRLP(buf)
    fmt.Printf("%x\n", buf)

    //fmt.Println(reflect.TypeOf(blk))
    //fmt.Printf("%s", blk.EncodeRLP())
    }