Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Documentation #73

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 11 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,27 @@
# w3
# `w3`: Enhanced Ethereum Integration for Go

[![Go Reference](https://pkg.go.dev/badge/github.com/lmittmann/w3.svg)](https://pkg.go.dev/github.com/lmittmann/w3)
[![Go Report Card](https://goreportcard.com/badge/github.com/lmittmann/w3)](https://goreportcard.com/report/github.com/lmittmann/w3)
[![Coverage Status](https://coveralls.io/repos/github/lmittmann/w3/badge.svg?branch=main)](https://coveralls.io/github/lmittmann/w3?branch=main)
[![Latest Release](https://img.shields.io/github/v/release/lmittmann/w3)](https://github.com/lmittmann/w3/releases)
<img src="https://w3.cool/gopher.png" align="right" alt="W3 Gopher" width="158" height="224">

<img src="https://user-images.githubusercontent.com/3458786/153202258-24bf253e-5ab0-4efd-a0ed-43dc1bf093c9.png" align="right" alt="W3 Gopher" width="158" height="224">
`w3` is your toolbelt for integrating with Ethereum in Go. Closely linked to `go-ethereum`, it provides an ergonomic wrapper for working with **RPC**, **ABI's**, and the **EVM**.

Package `w3` implements a blazing fast and modular Ethereum JSON RPC client with
first-class ABI support.

* **Batch request** support significantly reduces the duration of requests to
both remote and local endpoints.
* **ABI** bindings are specified for individual functions using Solidity syntax.
No need for `abigen` and ABI JSON files.
* **Modular** API allows to create custom RPC method integrations that can be
used alongside the methods implemented by the package.

`w3` is closely linked to [go-ethereum](https://github.com/ethereum/go-ethereum)
and uses a variety of its types, such as [`common.Address`](https://pkg.go.dev/github.com/ethereum/go-ethereum/common#Address)
or [`types.Transaction`](https://pkg.go.dev/github.com/ethereum/go-ethereum/core/types#Transaction).

Batch requests with `w3` are up to **85x faster** than sequential requests with
`go-ethereum/ethclient`.

<details>
<summary>Benchmarks</summary>
<pre>
name ethclient time/op w3 time/op delta
Call_BalanceNonce 78.3ms ± 2% 39.0ms ± 1% -50.15% (p=0.000 n=23+22)
Call_Balance100 3.90s ± 5% 0.05s ± 2% -98.84% (p=0.000 n=20+24)
Call_BalanceOf100 3.99s ± 3% 0.05s ± 2% -98.73% (p=0.000 n=22+23)
Call_Block100 6.89s ± 7% 1.94s ±11% -71.77% (p=0.000 n=24+23)
</pre>
</details>

## Install

```
go get github.com/lmittmann/w3
```


## At a Glance

* Use [`w3.Client`](https://pkg.go.dev/github.com/lmittmann/w3#Client) to connect to an RPC endpoint. The client features batch request support for up to **80x faster requests** and easy extendibility.
* Use [`w3vm.VM`](https://pkg.go.dev/github.com/lmittmann/w3/w3vm#VM) to simulate EVM execution with optional tracing and Mainnet state forking, or test Smart Contracts.
* Use [`w3.Func`](https://pkg.go.dev/github.com/lmittmann/w3#Func) and [`w3.Event`](https://pkg.go.dev/github.com/lmittmann/w3#Event) to create ABI bindings from Solidity function and event signatures.
* Use [`w3.A`](https://pkg.go.dev/github.com/lmittmann/w3#A), [`w3.H`](https://pkg.go.dev/github.com/lmittmann/w3#H), and many other utility functions to parse addresses, hashes, and other common types from strings.


## Getting Started

> **Note**
Expand Down
23 changes: 23 additions & 0 deletions docs/components/RefLink.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Link } from 'nextra-theme-docs'
import { Code } from 'nextra/components'

const pkgNameToPath = {
'w3': 'w3',
'module': 'w3/module',
'debug': 'w3/module/debug',
'eth': 'w3/module/eth',
'txpool': 'w3/module/txpool',
'web3': 'w3/module/web3',
'w3types': 'w3/w3types',
'w3vm': 'w3/w3vm',
}

export const RefLink = ({ title }) => {
let [pkg, comp] = title.split('.', 2)
let url = `https://pkg.go.dev/github.com/lmittmann/${pkgNameToPath[pkg]}#${comp}`
return (
<Link href={url}>
<Code>{title}</Code>
</Link>
)
}
8 changes: 8 additions & 0 deletions docs/jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@components/*": ["components/*"]
}
}
}
5 changes: 3 additions & 2 deletions docs/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ const withNextra = nextra({
theme: 'nextra-theme-docs',
themeConfig: './theme.config.jsx',
staticImage: true,
flexsearch: {
codeblocks: false
search: {
codeblocks: true
},
defaultShowCopyCode: true
})

export default withNextra({
output: 'export',
reactStrictMode: true,
images: {
unoptimized: true,
Expand Down
14 changes: 7 additions & 7 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
"type": "module",
"scripts": {
"dev": "next dev",
"build": "next build && next export"
"build": "next build"
},
"dependencies": {
"next": "^13.4.19",
"nextra": "^2.12.3",
"nextra-theme-docs": "^2.12.3",
"next": "^14.1.0",
"nextra": "3.0.0-alpha.13",
"nextra-theme-docs": "3.0.0-alpha.13",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"autoprefixer": "^10.4.15",
"postcss": "^8.4.29",
"tailwindcss": "^3.3.3"
"autoprefixer": "^10.4.17",
"postcss": "^8.4.33",
"tailwindcss": "^3.4.1"
}
}
28 changes: 28 additions & 0 deletions docs/pages/_meta.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
export default {
examples: {
title: 'Examples ↗',
type: 'page',
href: '/examples',
newWindow: true
},
godoc: {
title: 'GoDoc ↗',
type: 'page',
href: 'https://pkg.go.dev/github.com/lmittmann/w3#section-documentation',
newWindow: true
},
index: {
title: 'Introduction',
theme: {
toc: false,
breadcrumb: false,
},
},
rpc: 'RPC',
vm: 'VM',
abi: 'ABI',
'-- Examples': {
type: 'separator',
title: 'Examples'
},
}
18 changes: 0 additions & 18 deletions docs/pages/_meta.json

This file was deleted.

5 changes: 0 additions & 5 deletions docs/pages/abi.mdx
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
---
title: ABI Bindings
draft: true
---

# ABI

ABI bindings allow the encoding and decoding of Smart Contract function calls or the decoding of events.
Expand Down
Loading
Loading