laconicd/ethereum/rpc/web3_api.go

27 lines
703 B
Go
Raw Normal View History

2021-04-18 16:39:15 +00:00
package rpc
2018-08-09 10:36:47 +00:00
import (
2021-04-18 16:39:15 +00:00
"github.com/cosmos/ethermint/version"
2018-08-09 10:36:47 +00:00
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/crypto"
)
2018-08-09 10:36:47 +00:00
// PublicWeb3API is the web3_ prefixed set of APIs in the Web3 JSON-RPC spec.
type PublicWeb3API struct{}
2018-08-09 10:36:47 +00:00
2021-04-18 16:39:15 +00:00
// NewPublicWeb3API creates an instance of the Web3 API.
func NewPublicWeb3API() *PublicWeb3API {
2018-08-09 10:36:47 +00:00
return &PublicWeb3API{}
}
// ClientVersion returns the client version in the Web3 user agent format.
2021-04-18 16:39:15 +00:00
func (a *PublicWeb3API) ClientVersion() string {
2021-04-18 17:23:26 +00:00
return version.Version()
2018-08-09 10:36:47 +00:00
}
// Sha3 returns the keccak-256 hash of the passed-in input.
2021-04-18 16:39:15 +00:00
func (a *PublicWeb3API) Sha3(input hexutil.Bytes) hexutil.Bytes {
2018-08-09 10:36:47 +00:00
return crypto.Keccak256(input)
}