Skip to content

AccumulatedFinance/ethereum-ledger-go

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ethereum-ledger-go

This package is a general-purpose Ethereum Ledger library adapted from go-ethereum for applications written in Go. It is currently in Beta and experimental, with plans to be production-ready shortly.

Usage

Initialize Wallet

import (
 	ethLedger "github.com/AccumulatedFinance/ethereum-ledger-go"
	"github.com/AccumulatedFinance/ethereum-ledger-go/accounts"
)

ledger, err := ethLedger.New()

wallet := ledger.Wallets()[0]     // Use first USB device detected
err = wallet.Open("")

path := accounts.DefaultBaseDerivationPath      // m/44'/60'/0'/0/0
account, err := wallet.Derive(path, true)       // Boolean indicates whether the account should be cached on the wallet

Sign Transactions

import ethLedger "github.com/AccumulatedFinance/ethereum-ledger-go"
import "math/big"

tx := ethLedger.CreateTx(
  3,                   // Nonce
  big.NewInt(10),      // GasPrice
  10,                  // Gas
  addr,                // To
  big.NewInt(10),      // Value
  make([]byte, 0),     // Data
)

// Initialize Wallet
sigBytes, err := wallet.SignTx(
  account,              // Wallet Account
  tx,                   // Tx
  big.NewInt(0)         // Chain ID
)

Sign Typed Data

import "github.com/ethereum/go-ethereum/signer/core/apitypes"

// First, create a typedData object that conforms to apitypes.TypedData
// (see tests/integration_test.go for a complete example)
sigBytes, err := wallet.SignTypedData(
  account,          // Wallet Account
  typedData         // EIP-712 conformant Typed Data
)

Notes

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%