laconicd/rpc/ethereum/namespaces/web3/api.go
WilliamXieCrypto 01bc2ec170
fix: Update the JSON-RPC to correct the return information. (#1006)
* fix: Update the JSON-RPC to correct the return information.

* Update CHANGELOG.md

* update: move the tests to integration_test.go

* refactor the tests and use table tests instead

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
2022-03-21 11:40:24 +00:00

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))
}