c25669c761
* rpc: refactor rpc packages and backend to support cosmos namespace * changelog * typo
27 lines
681 B
Go
27 lines
681 B
Go
package web3
|
|
|
|
import (
|
|
"github.com/tharsis/ethermint/version"
|
|
|
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
|
"github.com/ethereum/go-ethereum/crypto"
|
|
)
|
|
|
|
// PublicAPI is the web3_ prefixed set of APIs in the Web3 JSON-RPC spec.
|
|
type PublicAPI struct{}
|
|
|
|
// NewPublicAPI creates an instance of the Web3 API.
|
|
func NewPublicAPI() *PublicAPI {
|
|
return &PublicAPI{}
|
|
}
|
|
|
|
// ClientVersion returns the client version in the Web3 user agent format.
|
|
func (a *PublicAPI) ClientVersion() string {
|
|
return version.Version()
|
|
}
|
|
|
|
// Sha3 returns the keccak-256 hash of the passed-in input.
|
|
func (a *PublicAPI) Sha3(input string) hexutil.Bytes {
|
|
return crypto.Keccak256(hexutil.Bytes(input))
|
|
}
|