2021-06-23 06:38:05 +00:00
|
|
|
package web3
|
|
|
|
|
|
|
|
import (
|
2022-09-07 06:36:11 +00:00
|
|
|
"github.com/cerc-io/laconicd/version"
|
2021-06-23 06:38:05 +00:00
|
|
|
|
|
|
|
"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.
|
2022-03-21 11:40:24 +00:00
|
|
|
func (a *PublicAPI) Sha3(input string) hexutil.Bytes {
|
|
|
|
return crypto.Keccak256(hexutil.Bytes(input))
|
2021-06-23 06:38:05 +00:00
|
|
|
}
|