Categorygithub.com/offchainlabs/go-solidity-sha3
modulepackage
0.1.2
Repository: https://github.com/offchainlabs/go-solidity-sha3.git
Documentation: pkg.go.dev

# README


logo


go-solidity-sha3

Generate Solidity SHA3 (Keccak256) hashes in Go.

License Build Status Go Report Card GoDoc

This package is the Go equivalent of require('ethers').utils.solidityKeccak256 NPM module.

Install

go get -u github.com/miguelmota/go-solidity-sha3

Documentation

Documentation on GoDoc

Getting started

Simple example:

package main

import (
	"encoding/hex"
	"fmt"

	"github.com/miguelmota/go-solidity-sha3"
)

func main() {
	hash := solsha3.SoliditySHA3(
		// types
		[]string{"address", "uint256"},

		// values
		[]interface{}{
			"0x935F7770265D0797B621c49A5215849c333Cc3ce",
			"100000000000000000",
		},
	)

	fmt.Println(hex.EncodeToString(hash))
}

Output:

0a3844b522d9e3a837ae56d4c57d668feb26325834bf4ba49e153d84ed7ad53d

More complex example:

package main

import (
	"encoding/hex"
	"fmt"

	"github.com/miguelmota/go-solidity-sha3"
)

func main() {
	types := []string{"address", "bytes1", "uint8[]", "bytes32", "uint256", "address[]", "uint32"}
	values := []interface{}{
		"0x935F7770265D0797B621c49A5215849c333Cc3ce",
		"0xa",
		[]uint8{128, 255},
		"100000000000000000",
		[]string{
			"0x13D94859b23AF5F610aEfC2Ae5254D4D7E3F191a",
			"0x473029549e9d898142a169d7234c59068EDcBB33",
		},
		123456789,
	}

	hash := solsha3.SoliditySHA3(types, values)

	fmt.Println(hex.EncodeToString(hash))
}

Output:

ad390a98c1c32cdb1f046f6887a4109f12290b690127e6e15da4ca210235510e

License

MIT

# Packages

No description provided by the author
No description provided by the author

# Functions

Address address.
AddressArray address.
Bool bool.
BoolArray bool array.
Bytes16 bytes16.
Bytes32 bytes32.
ConcatByteSlices concat byte slices.
Int128 int128.
Int128Array int128 array.
Int16 int16.
Int16Array int16 array.
Int256 int256.
Int256Array int256 array.
Int32 int32.
Int32Array int32.
Int64 int64.
Int64Array int64 array.
Int8 int8.
Int8Array int8 array.
Pack ...
SoliditySHA3 solidity sha3.
SoliditySHA3WithPrefix solidity sha3 with prefix.
String string.
StringArray string.
Uint128 uint128.
Uint128Array uint128.
Uint16 uint16.
Uint16Array uint16 array.
Uint256 uint256.
Uint256Array uint256 array.
Uint32 uint32.
Uint32Array uint32 array.
Uint64 uint64.
Uint64Array uint64 array.
Uint8 uint8.
Uint8Array uint8 array.