Ether Binder
Set of utilities for interacting with Ethereum and it's smart contracts with PHP, with generating ABI bindings and Ethereum-related types
|
Public Member Functions | |
__construct (protected string $message, protected ?Address $from=null, protected ?Signature $sig=null) | |
setMessage (string $message) | |
getMessage () | |
sign (Key $key) | |
isSigned () | |
toJson (bool $pretty) | |
__toString () | |
getSignature () | |
validateSignature () | |
Static Public Member Functions | |
static | fromJSON (string $json) |
Protected Member Functions | |
preProcessMessage () | |
AbstractSigningMessage is class for handling Ethereum signed messages, regardless of specific formatting which is offloaded to class extending AbstractSigningMessage. This allows for easy implementation of multiple signing formats offered by different wallets, usually small variations of "\x19Ethereum Signed Message:\n(len)(message)"
M8B\EtherBinder\Misc\AbstractSigningMessage::__construct | ( | protected string | $message, |
protected ?Address | $from = null, | ||
protected ?Signature | $sig = null ) |
Initializes the object with the message, from address and signature.
string | $message | The message to be signed. |
Address | null | $from | Ethereum address sending the message. Optional. |
Signature | null | $sig | Existing signature. Optional. |
M8B\EtherBinder\Misc\AbstractSigningMessage::__toString | ( | ) |
Default to string behaviour is pretty printed JSON.
EthBinderLogicException |
|
static |
Creates signed message from JSON string. Does not on its own validate the message, just parses it into object.
string | $json | JSON object of message |
BadAddressChecksumException | |
EthBinderLogicException | |
InvalidHexException | |
InvalidHexLengthException | |
JsonException |
M8B\EtherBinder\Misc\AbstractSigningMessage::getMessage | ( | ) |
Get the current message.
M8B\EtherBinder\Misc\AbstractSigningMessage::getSignature | ( | ) |
Retrieve the signature object.
M8B\EtherBinder\Misc\AbstractSigningMessage::isSigned | ( | ) |
Check if message is signed.
|
abstractprotected |
Preprocess the message before hashing, for example adding signing "magic bytes" such as "\x19Ethereum Signed Message" etc. This allows for multiple formats support
Reimplemented in M8B\EtherBinder\Misc\GethLikeMessage, M8B\EtherBinder\Misc\InnerHashedMessage, and M8B\EtherBinder\Misc\UnFormattedSigningMessage.
M8B\EtherBinder\Misc\AbstractSigningMessage::setMessage | ( | string | $message | ) |
Set the message. This will invalidate and remove the current signature if message is different from currently set and if signature is present
string | $message | The new message. |
M8B\EtherBinder\Misc\AbstractSigningMessage::sign | ( | Key | $key | ) |
Sign the message.
Key | $key | Private key for signing. |
EthBinderLogicException |
M8B\EtherBinder\Misc\AbstractSigningMessage::toJson | ( | bool | $pretty | ) |
Convert object state to JSON string, producing JSON object similar to MEW and other wallets that support signing
bool | $pretty | Use JSON pretty print option if true. |
EthBinderLogicException |
M8B\EtherBinder\Misc\AbstractSigningMessage::validateSignature | ( | ) |
Validate if the existing signature matches address it claims to be from.
EthBinderLogicException | |
EthBinderRuntimeException |