Documentation

GethLikeMessage extends AbstractSigningMessage
in package

GethLikeMessage is a subclass of AbstractSigningMessage that pre-processes messages in a way that Geth does.

The message gets prepended with "\x19Ethereum Signed Message:\n" followed by the message length, to align with Geth's signing method.

Tags
author

DubbaThony

Table of Contents

Properties

$from  : Address|null
$message  : string
$sig  : Signature|null

Methods

__construct()  : mixed
Initializes the object with the message, from address and signature.
__toString()  : string
Default to string behaviour is pretty printed JSON.
fromJSON()  : static
Creates signed message from JSON string. Does not on its own validate the message, just parses it into object.
getMessage()  : string
Get the current message.
getSignature()  : Signature
Retrieve the signature object.
isSigned()  : bool
Check if message is signed.
setMessage()  : void
Set the message. This will invalidate and remove the current signature if message is different from currently set and if signature is present
sign()  : Signature
Sign the message.
toJson()  : string
Convert object state to JSON string, producing JSON object similar to MEW and other wallets that support signing
validateSignature()  : bool
Validate if the existing signature matches address it claims to be from.
preProcessMessage()  : string
Preprocess the message before hashing, for example adding signing "magic bytes" such as "\x19Ethereum Signed Message" etc.
getMessageHash()  : Hash

Properties

Methods

__construct()

Initializes the object with the message, from address and signature.

public __construct(string $message[, Address|null $from = null ][, Signature|null $sig = null ]) : mixed
Parameters
$message : string

The message to be signed.

$from : Address|null = null

Ethereum address sending the message. Optional.

$sig : Signature|null = null

Existing signature. Optional.

getMessage()

Get the current message.

public getMessage() : string
Return values
string

The current message.

isSigned()

Check if message is signed.

public isSigned() : bool
Return values
bool

True if message has been signed, false otherwise.

setMessage()

Set the message. This will invalidate and remove the current signature if message is different from currently set and if signature is present

public setMessage(string $message) : void
Parameters
$message : string

The new message.

toJson()

Convert object state to JSON string, producing JSON object similar to MEW and other wallets that support signing

public toJson(bool $pretty) : string
Parameters
$pretty : bool

Use JSON pretty print option if true.

Tags
throws
EthBinderLogicException
Return values
string

The object state as a JSON string.

preProcessMessage()

Preprocess the message before hashing, for example adding signing "magic bytes" such as "\x19Ethereum Signed Message" etc.

protected preProcessMessage() : string

This allows for multiple formats support

Return values
string

The pre-processed message.


        
On this page

Search results