ethereum_util
library
Functions
addHexPrefix (String str )
→ String
Adds "0x" to a given String if it does not already start with "0x".
arrayContainsArray (List superset , List subset , {bool some = false })
→ bool
Returns TRUE if the first specified array contains all elements from the second one. FALSE otherwise.
baToJSON (dynamic ba )
→ dynamic
Converts a Uint8List or List<Uint8List> to JSON.
bufferToHex (Uint8List buf )
→ String
Converts a Uint8List into a hex String .
bufferToInt (Uint8List buf )
→ int
Converts a Uint8List to a int .
bytesToHex (List <int > bytes , {bool include0x = false , int ? forcePadLength , bool padToEvenLength = false })
→ String
concatSig (Uint8List r , Uint8List s , Uint8List v )
→ String
decode (Uint8List input , [bool stream = false ])
→ dynamic
decodeBigInt (List <int > bytes )
→ BigInt
elementaryName (String name )
→ String
encode (dynamic input )
→ Uint8List
encodeBigInt (BigInt input , {Endian endian = Endian.be , int length = 0 })
→ Uint8List
encodeLength (int length , int offset )
→ Uint8List
encodeSingle (String type , dynamic arg )
→ Uint8List
eventID (String name , List <String > types )
→ Uint8List
fromAscii (String stringValue )
→ String
Should be called to get hex representation (prefixed by 0x) of ascii string
fromRpcSig (String sig )
→ ECDSASignature
Convert signature format of the eth_sign
RPC method to signature parameters
NOTE: all because of a bug in geth: https://github.com/ethereum/go-ethereum/issues/2053
fromSigned (Uint8List signedInt )
→ BigInt
Interprets a Uint8List as a signed integer and returns a BigInt . Assumes 256-bit numbers.
fromUtf8 (String stringValue )
→ String
Should be called to get hex representation (prefixed by 0x) of utf8 string
generateNewPrivateKey (Random random )
→ BigInt ?
Generates a new private key using the random instance provided.
getBinarySize (String str )
→ int
Get the binary size of a string
hashPersonalMessage (dynamic message )
→ Uint8List
Returns the keccak-256 hash of message
, prefixed with the header used by the eth_sign
RPC call. The output of this function
can be fed into ecsign
to produce the same signature as the eth_sign
call for a given message
, or fed to ecrecover
along
with a signature to recover the public key used to produce the signature.
hexToBytes (String hexStr )
→ Uint8List
intToBuffer (dynamic i )
→ Uint8List
Converts an int or BigInt to a Uint8List
intToHex (dynamic i )
→ String
Converts a int into a hex String
isArray (String type )
→ bool
isDynamic (String type )
→ bool
Is a type dynamic?
isHexPrefixed (String str )
→ bool
isHexString (String value , {int length = 0 })
→ bool
Is the string a hex string.
isValidSignature (BigInt r , BigInt s , int v , {bool homesteadOrLater = true , int chainId = -1 })
→ bool
keccak (dynamic a , {int bits = 256 })
→ Uint8List
Creates Keccak hash of the input
keccak256 (dynamic a )
→ Uint8List
Creates Keccak-256 hash of the input, alias for keccak(a, 256).
methodID (String name , List <String > types )
→ Uint8List
padToEven (String value )
→ String
Pads a String to have an even length
parseNumber (dynamic arg )
→ BigInt
parseTypeArray (String type )
→ dynamic
Parse N in type<N>
where "type" can itself be an array type.
parseTypeN (String type )
→ int
Parse N from type
parseTypeNxM (String type )
→ List <int >
Parse N,M from type
privateKeyToAddress (Uint8List privateKey )
→ Uint8List
privateKeyToPublicKey (Uint8List privateKey )
→ Uint8List
Generates a public key for the given private key using the ecdsa curve which Ethereum uses.
processMessage (dynamic message )
→ Uint8List
delete message prefix 0x9c
publicKeyToAddress (Uint8List publicKey )
→ Uint8List
Constructs the Ethereum address associated with the given public key by taking the lower 160 bits of the key's sha3 hash.
rawEncode (List <String > types , dynamic values )
→ Uint8List
recoverPublicKeyFromSignature (ECDSASignature sig , Uint8List message , {int chainId = -1 })
→ Uint8List
ripemd160 (dynamic a , {bool padded = false })
→ Uint8List
Creates RIPEMD160 hash of the input.
rlphash (dynamic a )
→ Uint8List
Creates SHA-3 hash of the RLP encoded version of the input.
safeParseInt (String v , [int base = 10 ])
→ int
setLength (Uint8List msg , int length , {bool right = false })
→ Uint8List
setLengthLeft (Uint8List msg , int length , {bool right = false })
→ Uint8List
Left Pads an Uint8List with leading zeros till it has length
bytes. Or it truncates the beginning if it exceeds.
setLengthRight (Uint8List msg , int length )
→ Uint8List
Right Pads an Uint8List with leading zeros till it has length
bytes. Or it truncates the beginning if it exceeds.
sha256 (dynamic a )
→ Uint8List
Creates SHA256 hash of the input.
sha3 (Uint8List input )
→ Uint8List
sign (Uint8List message , Uint8List privateKey , {int chainId = -1 })
→ ECDSASignature
Signs the hashed data in message
using the given private key.
signTypedData ({required Uint8List privateKey , required String jsonData , required TypedDataVersion version })
→ String
Sign typed data, support all versions
signTypedDataCompact ({required Uint8List privateKey , required String jsonData , required TypedDataVersion version })
→ String
stringToBuffer (String i )
→ Uint8List
stripHexPrefix (String str )
→ String
stripZeros (Uint8List a )
→ Uint8List
toAscii (String hexString )
→ String
Should be called to get ascii from it's hex representation
toBuffer (dynamic v )
→ Uint8List
Attempts to turn a value into a Uint8List . As input it supports Uint8List , String , int , null
, BigInt method.
toRpcSig (BigInt r , BigInt s , int v , {int chainId = -1 })
→ String
Convert signature parameters into the format of eth_sign
RPC method.
toUnsigned (BigInt unsignedInt )
→ Uint8List
Converts a BigInt to an unsigned integer and returns it as a Uint8List . Assumes 256-bit numbers.
toUtf8 (String hexString )
→ String
Should be called to get utf8 from it's hex representation
unpad (Uint8List a )
→ Uint8List
Trims leading zeros from a Uint8List .
unpadString (String a )
→ String
zeros (int bytes )
→ Uint8List
Returns a buffer filled with 0s.