github.com/0xPolygon/supernets2-node@v0.0.0-20230711153321-2fe574524eaa/jsonrpc/endpoints_web3.go (about) 1 package jsonrpc 2 3 import ( 4 "math/big" 5 6 zkevm "github.com/0xPolygon/supernets2-node" 7 "github.com/0xPolygon/supernets2-node/jsonrpc/types" 8 "golang.org/x/crypto/sha3" 9 ) 10 11 // Web3Endpoints contains implementations for the "web3" RPC endpoints 12 type Web3Endpoints struct { 13 } 14 15 // ClientVersion returns the client version. 16 func (e *Web3Endpoints) ClientVersion() (interface{}, types.Error) { 17 return zkevm.Version, nil 18 } 19 20 // Sha3 returns the keccak256 hash of the given data. 21 func (e *Web3Endpoints) Sha3(data types.ArgBig) (interface{}, types.Error) { 22 b := (*big.Int)(&data) 23 hash := sha3.NewLegacyKeccak256() 24 hash.Write(b.Bytes()) //nolint:errcheck,gosec 25 keccak256Hash := hash.Sum(nil) 26 return types.ArgBytes(keccak256Hash), nil 27 }