eth-rpc-on-aws-lambda

command module
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2018 License: MIT Imports: 15 Imported by: 0

README

Ethereum Proxy on AWS Lambda

License Go Report Card GoDoc

AWS Lambda project as ethereum proxy following JSON-RPC, written in Golang. In addition, this project try porting web3 to Golang. Furthermore it applied IPFS API here to overwhelm limited storage of blockchain.

Contents

Features

  1. JSON-RPC relay with Ethereum node
  2. Proofs for sign and merkle tree such as Ecrecover, DeriveSha, VerifyProof and so on
  3. Sign, SignTx with encrypted private key on DynamoDB/Local
  4. IPFS interface
  5. fromWei, toWei written in Golang

Prerequisite

  1. Go
  1. dep
  • Install
brew install dep
  1. Docker
  1. xgo
  • because of compilation for C code used in go-ethereum, we need improved cross-compiler
docker pull karalabe/xgo-latest
go get github.com/karalabe/xgo

Build

  1. Move to root directory of this repo
  2. Build on your preference
  • In case of Lambda that is cross-compile, make or make lambda
  • In case of Lambda with remote branch, make branch=master remote
  • In case of local machine compile, make local

Test

  1. Move each module directory such as json, rpc and so on
  2. Run testunit
go test -v

Usage

  1. $> proxy [KEY_JSON_PATH] -log_lev=debug -log_out=/log/proxy.log -log_fmt=json
  2. $> proxy [KEY_JSON_PATH] [KEY_JSON_PASSPHRASE] -log_lev=debug -log_out=/log/proxy.log -log_fmt=json
  • path and passphrase for key json are NECESSARY now for crypto module.
  • log_lev, log_out, log_fmt, log_bot_token and log_bot_chatid are optional
  • description:
    • log_lev: log level
    • log_out: log output location
    • log_fmt: log format, text or JSON
    • log_bot_token: telegram access token
    • log_bot_chatid: telegram chat ID
  • default:
    • log_lev: info
    • log_out: stdout
    • log_fmt: text

Deploy (for AWS Lambda)

  1. Set Lambda on AWS
  • Function package: compressed binary file in $GOPATH/src/{repo}/bin
  • Handler: eth-proxy (binary file name, it is optional)
  • Runtime: Go 1.x
  • (Optional) Include DynamoDB execution role to Lambda execution role
  1. Set API Gateway as proxy on AWS
  2. Add API Gateway as Lambda trigger
  3. Add CloudWatch Logs

Reference

[1] AWS Lambda Go, https://github.com/aws/aws-lambda-go

[2] Go ethereum, https://github.com/ethereum/go-ethereum

[3] IPFS, https://ipfs.io/

[4] IPFS API, https://github.com/ipfs/go-ipfs-api

[5] Cross compiling for ethereum, https://github.com/ethereum/go-ethereum/wiki/Cross-compiling-Ethereum

[6] Xgo, https://github.com/karalabe/xgo

[7] Dep, https://github.com/golang/dep

License

MIT

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package abi implements smart contract call helper
Package abi implements smart contract call helper
Package common includes utility and constants such as unit (wei, ether)
Package common includes utility and constants such as unit (wei, ether)
Package crypto is combined crypto module for both general(AES, ...) and ethereum(Ecrevoer, sign, ...)
Package crypto is combined crypto module for both general(AES, ...) and ethereum(Ecrevoer, sign, ...)
Package db is a DB helper interface for AWS DynamoDB
Package db is a DB helper interface for AWS DynamoDB
Package ipfs is a IPFS interface
Package ipfs is a IPFS interface
Package json is a JSON parser for request & response body used in JSON-RPC
Package json is a JSON parser for request & response body used in JSON-RPC
Package log is wrapper for logging
Package log is wrapper for logging
Package predefined manages predefined functions for RPC request
Package predefined manages predefined functions for RPC request
Package rpc invokes JSON-RPC with ethereum node
Package rpc invokes JSON-RPC with ethereum node
Package web3 is converted golang layer from web3.js
Package web3 is converted golang layer from web3.js

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL