Skip to content
cryptoddevPublic

About

Minimal Ethereum RPC client in Go. fasthttp, WebSocket, Multicall2, EIP-1559.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fasteth — Ethereum RPC Client in Go

A high-performance Ethereum RPC client built on fasthttp and gobwas/ws. No go-ethereum dependency.

Features

  • Fasthttp-based HTTP — 3–5x faster than net/http for JSON-RPC
  • WebSocket subscriptions — real-time log and header streaming
  • Multicall2 — aggregate and tryAggregate with typed calls and automatic ABI decoding
  • Gas estimation — adaptive eth_estimateGas with automatic multiplier
  • Nonce management — concurrent-safe eth_getTransactionCount with caching
  • Transaction building — EIP-1559 (type 2) with legacy fallback, RLP encoding
  • Wallet — secp256k1 key management and signing (via decred/dcrd/secp256k1)
  • Price oracle — on-demand token price via known DEX pairs

Quick Start

import "github.com/cryptoddev/fasteth"

client := fasteth.NewClient("http://node:8545", "ws://node:8546")

// Direct eth_call
result, err := client.CallContract(ctx, &fasteth.CallMsg{
    To:   "0x...",
    Data: "0x70a08231...",
}, 0)

// Multicall aggregate
call := fasteth.BuildCall(pool, "factory()")
results, _ := client.Aggregate3(ctx, []fasteth.Call{call}, 100)

Multicall

Aggregate up to 100 calls in a single RPC request. Supports both aggregate and tryAggregate (per-call failure tolerance).

symCall := fasteth.BuildCall(token, "symbol()")
symCall.OutputTypes = []fastabi.ParamType{fastabi.TString()}

balCall := fasteth.BuildCallWithArgs(token, "balanceOf(address)",
    []fastabi.ParamType{fastabi.TAddress()},
    []any{userAddr},
)

results, _ := client.Aggregate3(ctx, []fasteth.Call{symCall, balCall}, 100)
for _, r := range results {
    if r.Success {
        log.Printf("decoded: %v", r.Decoded)
    }
}

Testing

# Unit tests
go test -short ./...

# Integration tests (requires a running RPC node)
go test -tags=integration -run TestMultiCall ./
go test -tags=integration -run TestAggregate3_RealNode .

License

MIT

About

Minimal Ethereum RPC client in Go. fasthttp, WebSocket, Multicall2, EIP-1559.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

⌂ 换网址