github.com/devfans/go-ethereum@v1.5.10-0.20170326212234-7419d0c38291/cmd/evm/main.go (about) 1 // Copyright 2014 The go-ethereum Authors 2 // This file is part of go-ethereum. 3 // 4 // go-ethereum is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // go-ethereum is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with go-ethereum. If not, see <http://www.gnu.org/licenses/>. 16 17 // evm executes EVM code snippets. 18 package main 19 20 import ( 21 "fmt" 22 "math/big" 23 "os" 24 25 "github.com/ethereum/go-ethereum/cmd/utils" 26 "gopkg.in/urfave/cli.v1" 27 ) 28 29 var gitCommit = "" // Git SHA1 commit hash of the release (set via linker flags) 30 31 var ( 32 app = utils.NewApp(gitCommit, "the evm command line interface") 33 34 DebugFlag = cli.BoolFlag{ 35 Name: "debug", 36 Usage: "output full trace logs", 37 } 38 CodeFlag = cli.StringFlag{ 39 Name: "code", 40 Usage: "EVM code", 41 } 42 CodeFileFlag = cli.StringFlag{ 43 Name: "codefile", 44 Usage: "file containing EVM code", 45 } 46 GasFlag = cli.Uint64Flag{ 47 Name: "gas", 48 Usage: "gas limit for the evm", 49 Value: 10000000000, 50 } 51 PriceFlag = utils.BigFlag{ 52 Name: "price", 53 Usage: "price set for the evm", 54 Value: new(big.Int), 55 } 56 ValueFlag = utils.BigFlag{ 57 Name: "value", 58 Usage: "value set for the evm", 59 Value: new(big.Int), 60 } 61 DumpFlag = cli.BoolFlag{ 62 Name: "dump", 63 Usage: "dumps the state after the run", 64 } 65 InputFlag = cli.StringFlag{ 66 Name: "input", 67 Usage: "input for the EVM", 68 } 69 VerbosityFlag = cli.IntFlag{ 70 Name: "verbosity", 71 Usage: "sets the verbosity level", 72 } 73 CreateFlag = cli.BoolFlag{ 74 Name: "create", 75 Usage: "indicates the action should be create rather than call", 76 } 77 DisableGasMeteringFlag = cli.BoolFlag{ 78 Name: "nogasmetering", 79 Usage: "disable gas metering", 80 } 81 ) 82 83 func init() { 84 app.Flags = []cli.Flag{ 85 CreateFlag, 86 DebugFlag, 87 VerbosityFlag, 88 CodeFlag, 89 CodeFileFlag, 90 GasFlag, 91 PriceFlag, 92 ValueFlag, 93 DumpFlag, 94 InputFlag, 95 DisableGasMeteringFlag, 96 } 97 app.Commands = []cli.Command{ 98 compileCommand, 99 disasmCommand, 100 runCommand, 101 } 102 } 103 104 func main() { 105 if err := app.Run(os.Args); err != nil { 106 fmt.Fprintln(os.Stderr, err) 107 os.Exit(1) 108 } 109 }