aboutsummaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
Diffstat (limited to 'plugin')
-rw-r--r--plugin/evm/config.go1
-rw-r--r--plugin/evm/service.go12
-rw-r--r--plugin/evm/vm.go4
-rw-r--r--plugin/params.go1
4 files changed, 17 insertions, 1 deletions
diff --git a/plugin/evm/config.go b/plugin/evm/config.go
index 4d6650a..21b3aaf 100644
--- a/plugin/evm/config.go
+++ b/plugin/evm/config.go
@@ -16,6 +16,7 @@ type CommandLineConfig struct {
PersonalAPIEnabled bool `json:"personal-api-enabled"`
TxPoolAPIEnabled bool `json:"tx-pool-api-enabled"`
DebugAPIEnabled bool `json:"debug-api-enabled"`
+ Web3APIEnabled bool `json:"web3-api-enabled"`
ParsingError error
}
diff --git a/plugin/evm/service.go b/plugin/evm/service.go
index a934941..7b8368e 100644
--- a/plugin/evm/service.go
+++ b/plugin/evm/service.go
@@ -19,11 +19,12 @@ import (
"github.com/ava-labs/avalanchego/utils/json"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
+ ethcrypto "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"
)
const (
- version = "coreth-v0.3.7"
+ version = "coreth"
)
// test constants
@@ -50,6 +51,15 @@ func (s *NetAPI) PeerCount() hexutil.Uint { return hexutil.Uint(0) } // TODO: re
// Version returns the current ethereum protocol version.
func (s *NetAPI) Version() string { return fmt.Sprintf("%d", s.vm.networkID) }
+// Web3API offers helper API methods
+type Web3API struct{}
+
+// ClientVersion returns the version of the vm running
+func (s *Web3API) ClientVersion() string { return version }
+
+// Sha3 returns the bytes returned by hashing [input] with Keccak256
+func (s *Web3API) Sha3(input hexutil.Bytes) hexutil.Bytes { return ethcrypto.Keccak256(input) }
+
// GetAcceptedFrontReply defines the reply that will be sent from the
// GetAcceptedFront API call
type GetAcceptedFrontReply struct {
diff --git a/plugin/evm/vm.go b/plugin/evm/vm.go
index c902f85..a8c4fc0 100644
--- a/plugin/evm/vm.go
+++ b/plugin/evm/vm.go
@@ -534,6 +534,10 @@ func (vm *VM) CreateHandlers() map[string]*commonEng.HTTPHandler {
handler.RegisterName("net", &NetAPI{vm})
enabledAPIs = append(enabledAPIs, "net")
}
+ if vm.CLIConfig.Web3APIEnabled {
+ handler.RegisterName("web3", &Web3API{})
+ enabledAPIs = append(enabledAPIs, "web3")
+ }
log.Info(fmt.Sprintf("Enabled APIs: %s", strings.Join(enabledAPIs, ", ")))
diff --git a/plugin/params.go b/plugin/params.go
index 6615798..a130d52 100644
--- a/plugin/params.go
+++ b/plugin/params.go
@@ -27,6 +27,7 @@ func init() {
cliConfig.PersonalAPIEnabled = true
cliConfig.TxPoolAPIEnabled = true
cliConfig.NetAPIEnabled = true
+ cliConfig.Web3APIEnabled = true
cliConfig.RPCGasCap = 2500000000 // 25000000 x 100
cliConfig.RPCTxFeeCap = 100 // 100 AVAX
} else {