wallet-adapter-eth
Module path: github.com/godaddy-x/wallet-adapter-eth
Ethereum and EVM-compatible chain wallet-adapter subclass implementation, providing a unified ChainAdapter for BSC, Polygon, Arbitrum, and others. Supports native coin and ERC20 transaction building, EIP-155 signing, and raw transaction broadcast, compatible with external MPC signing services; configuration is passed via LoadAssetsConfig callback, supporting multiple formats defined by wallet-adapter/config (JSON/INI, etc.).
Overview
- Base framework: wallet-adapter
ChainAdapter (SymbolInfo, AssetsConfig, TransactionDecoder, BlockScanner, AddressDecoder).
- Implementation highlights: Uses github.com/godaddy-x/wallet-adapter
types.RawTransaction, wallet.WalletDAI, etc.; implements decoder.TransactionDecoder, decoder.AddressDecoder, decoder.SmartContractDecoder; EVM chain config (WalletConfig) in internal/config, loaded via wallet-adapter/config Configer interface, supporting JSON/INI and other formats.
Project structure (by package)
wallet-adapter-eth/
├── go.mod
├── go.sum
├── main.go # entry point (one-line startup from JSON config)
├── build_release.bat, build_release.sh
├── .github/workflows/release.yml # tag → Release + SHA256SUMS
├── README.md
├── LICENSE
├── resource/
│ └── config.json # sample config (JSON format)
├── eth/ # public package: adapter and one-line startup
│ ├── doc.go
│ ├── adapter.go # EthAdapter, NewEthAdapter
│ └── run.go # NewAdapter(jsonContent, symbol, fullName, decimals)
└── internal/ # internal packages (module use only)
├── config/ # WalletConfig (EVM), BuildConfigFromConfiger (uses wallet-adapter/config Configer)
├── decoder/ # AddressDecoder, TransactionDecoder, SmartContractDecoder (github.com/godaddy-x/wallet-adapter/decoder)
│ ├── address.go
│ ├── transaction.go
│ └── contract.go
├── manager/ # WalletManager (RPC, nonce, gas, balance, broadcast)
│ └── manager.go
├── models/ # TxFeeInfo, AddrBalance, CallMsg
│ └── models.go
├── rpc/ # JSON-RPC client (Dial, Call, broadcast)
│ └── client.go
└── util/ # StringToBigInt, BigIntToDecimal, Append0x
├── addr.go
└── decimal.go
Dependencies
Official releases
Prebuilt binaries are available from GitHub Releases. Pushing a v* tag triggers .github/workflows/release.yml cross-compilation and release:
| Artifact |
Platform |
wallet-adapter-eth-linux-amd64 |
Linux x86_64 |
wallet-adapter-eth-linux-arm64 |
Linux ARM64 |
wallet-adapter-eth-darwin-amd64 |
macOS Intel (x86_64) |
wallet-adapter-eth-darwin-arm64 |
macOS Apple Silicon (ARM64) |
wallet-adapter-eth-windows-amd64.exe |
Windows x86_64 |
SHA256SUMS |
SHA-256 checksums for the above binaries |
Verify before deployment:
# Linux / macOS — run in download directory (ignore missing files when downloading single platform)
sha256sum -c --ignore-missing SHA256SUMS
# Windows — compare with wallet-adapter-eth-windows-amd64.exe line in SHA256SUMS
Get-FileHash .\wallet-adapter-eth-windows-amd64.exe -Algorithm SHA256
Maintainer release:
git tag v1.0.5
git push origin v1.0.5
Cross-compile (static link CGO_ENABLED=0, output in output/):
build_release.bat REM Windows
chmod +x build_release.sh && ./build_release.sh # Linux / macOS
Usage
1. One-line startup (create and register adapter from JSON content)
import (
"github.com/godaddy-x/wallet-adapter-eth/eth"
)
// jsonContent is a JSON config string, parsed via wallet-adapter/config MapConfig
// Supported fields: serverAPI, broadcastAPI, dataDir, chainID, fixGasLimit, fixGasPrice, offsetsGasPrice, gasPriceUpliftPercent, etc.
adapter, err := eth.NewAdapter(jsonContent, "ETH", "Ethereum", 18)
if err != nil {
return err
}
// adapter is *eth.EthAdapter, registered to chain, with RPC client set; fetches chainID from node if ChainID is 0
2. Set RPC and get decoders
import (
"github.com/godaddy-x/wallet-adapter/chain"
"github.com/godaddy-x/wallet-adapter-eth/eth"
"github.com/godaddy-x/wallet-adapter-eth/internal/rpc"
)
// Connect to node (read/write can be separated: broadcast uses BroadcastURL)
client, err := rpc.Dial("https://eth-mainnet.g.alchemy.com/v2/xxx", "https://eth-mainnet.g.alchemy.com/v2/yyy")
if err != nil {
return err
}
defer client.Close()
a, _ := chain.GetAdapter("ETH")
if e, ok := a.(*eth.EthAdapter); ok {
e.SetClient(client)
_, _ = e.SetNetworkChainID() // fetch chainId from node and write to Config
}
decoder, _ := chain.GetTransactionDecoder("ETH")
addressDecoder, _ := chain.GetAddressDecoder("ETH")
3. Build and broadcast transactions (with flow + WalletDAI)
import (
"github.com/godaddy-x/wallet-adapter/chain"
"github.com/godaddy-x/wallet-adapter/flow"
)
// wrapper must implement wallet.WalletDAI (SignPendingTxData, GetAddressList, etc.)
pending, err := flow.BuildTransaction(decoder, wrapper, rawTx)
// ... MPC signing fills pending.SignerList ...
tx, err := flow.SendTransaction(decoder, wrapper, pending)
4. Multi-chain (BSC, Polygon, Arbitrum)
To support multiple chains with the same code, use NewEthAdapter(symbol, fullName, decimals) then LoadAssetsConfig(c) to initialize config and RPC (c is github.com/godaddy-x/wallet-adapter/config.Configer or map[string]string):
import (
"github.com/godaddy-x/wallet-adapter/chain"
"github.com/godaddy-x/wallet-adapter/config"
"github.com/godaddy-x/wallet-adapter-eth/eth"
)
func registerEvmChains() {
chains := []struct{ symbol, fullName, api string }{
{"ETH", "Ethereum", "https://eth.llamarpc.com"},
{"BSC", "BNB Smart Chain", "https://bsc-dataseed.binance.org"},
{"MATIC", "Polygon", "https://polygon-rpc.com"},
{"ARB", "Arbitrum One", "https://arb1.arbitrum.io/rpc"},
}
for _, c := range chains {
adapter := eth.NewEthAdapter(c.symbol, c.fullName, 18)
chain.RegAdapter(c.symbol, adapter)
kv := map[string]string{"serverAPI": c.api, "broadcastAPI": c.api}
_ = adapter.LoadAssetsConfig(config.MapConfig(kv))
}
}
Current capabilities
| Capability |
Description |
| Native ETH transfer |
CreateRawTransaction / SubmitRawTransaction / VerifyRawTransaction |
| ERC20 transfer |
CreateRawTransaction (transfer tx when IsContract) / SubmitRawTransaction / VerifyRawTransaction |
| Fee rate |
GetRawTransactionFeeRate, EstimateRawTransactionFee |
| Summary |
CreateSummaryRawTransactionWithError (native coin only) |
| Address |
AddressDecode / AddressEncode / AddressVerify, PublicKeyToAddress (EVM 0x+20 bytes) |
| MPC signing |
Supports 64-byte R|S to 65-byte R|S|V, EIP-155 chainId |
| BlockScanner |
Implemented (EthBlockScanner); see internal/scanner |
Local testing (main + JSON)
Root main.go embeds a JSON example and blocks; optional -addr tests balance and nonce for a given address:
# Run directly (uses embedded JSON config in code)
go run .
# With address: prints balance and nonce
go run . -addr 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045
JSON config example in resource/config.json; configure serverAPI, broadcastAPI, dataDir, etc.
Documentation
| Location |
Description |
| This README |
Project overview, structure, dependencies, usage, capability table |
| eth/doc.go |
Public eth package docs and usage examples |
| internal/config |
EVM WalletConfig, BuildConfigFromConfiger (depends on github.com/godaddy-x/wallet-adapter/config) |
| internal/manager |
WalletManager, LoadAssetsConfig, RPC/balance/broadcast |
| internal/decoder |
AddressDecoder, TransactionDecoder, SmartContractDecoder (EVM/ERC20 token balance and metadata) |
| internal/rpc, models, util |
JSON-RPC client, internal models, decimal and address utilities |
| docs/PENDING_SIGN_VERIFY.md |
Pending sign verification and cross-check |
| internal/scanner/flow.md |
Block scanner flow documentation |
License
MIT