aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/abigen
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2016-03-18 01:27:37 +0800
committerPéter Szilágyi <peterke@gmail.com>2016-03-24 20:15:32 +0800
commit86cfc22c79594bd0d9625650dcbfb60c3e6ba9fe (patch)
treef080840b4ac808304862846125bf8b4d47a4ef37 /cmd/abigen
parent72826bb5adddedf0fd4fb9903e883d4c64fa18a6 (diff)
downloaddexon-86cfc22c79594bd0d9625650dcbfb60c3e6ba9fe.tar
dexon-86cfc22c79594bd0d9625650dcbfb60c3e6ba9fe.tar.gz
dexon-86cfc22c79594bd0d9625650dcbfb60c3e6ba9fe.tar.bz2
dexon-86cfc22c79594bd0d9625650dcbfb60c3e6ba9fe.tar.lz
dexon-86cfc22c79594bd0d9625650dcbfb60c3e6ba9fe.tar.xz
dexon-86cfc22c79594bd0d9625650dcbfb60c3e6ba9fe.tar.zst
dexon-86cfc22c79594bd0d9625650dcbfb60c3e6ba9fe.zip
accounts/abi/bind: constructor, auth utils and various backends
Diffstat (limited to 'cmd/abigen')
-rw-r--r--cmd/abigen/main.go17
1 files changed, 13 insertions, 4 deletions
diff --git a/cmd/abigen/main.go b/cmd/abigen/main.go
index d36784de8..227c390a6 100644
--- a/cmd/abigen/main.go
+++ b/cmd/abigen/main.go
@@ -27,9 +27,10 @@ import (
var (
abiFlag = flag.String("abi", "", "Path to the Ethereum contract ABI json to bind")
+ binFlag = flag.String("bin", "", "Path to the Ethereum contract bytecode (generate deploy method)")
pkgFlag = flag.String("pkg", "", "Go package name to generate the binding into")
typFlag = flag.String("type", "", "Go struct name for the binding (default = package name)")
- outFlag = flag.String("out", "", "Output path for the generated binding")
+ outFlag = flag.String("out", "", "Output path for the generated binding (default = stdout)")
)
func main() {
@@ -44,17 +45,25 @@ func main() {
fmt.Printf("No destination Go package specified (--pkg)\n")
os.Exit(-1)
}
- // Generate the contract binding
- in, err := ioutil.ReadFile(*abiFlag)
+ // Read the ABI json from disk and optionally the contract bytecode too
+ abi, err := ioutil.ReadFile(*abiFlag)
if err != nil {
fmt.Printf("Failed to read input ABI: %v\n", err)
os.Exit(-1)
}
+ bin := []byte{}
+ if *binFlag != "" {
+ if bin, err = ioutil.ReadFile(*binFlag); err != nil {
+ fmt.Printf("Failed to read input bytecode: %v\n", err)
+ os.Exit(-1)
+ }
+ }
+ // Generate the contract binding
kind := *typFlag
if kind == "" {
kind = *pkgFlag
}
- code, err := bind.Bind(string(in), *pkgFlag, kind)
+ code, err := bind.Bind(string(abi), string(bin), *pkgFlag, kind)
if err != nil {
fmt.Printf("Failed to generate ABI binding: %v\n", err)
os.Exit(-1)