V 2
Contracts
ECDSA
→ addressinternal
recover(bytes32 hash, bytes signature)Returns the address that signed a hashed message (hash
) with
signature
. This address can then be used for verification purposes.
The ecrecover
EVM opcode allows for malleable (non-unique) signatures:
this function rejects them by requiring the s
value to be in the lower
half order, and the v
value to be either 27 or 28.
(.note) This call does not revert if the signature is invalid, or if the signer is otherwise unable to be retrieved. In those scenarios, the zero address is returned.
(.warning) hash
must be the result of a hash operation for the
verification to be secure: it is possible to craft signatures that
recover to arbitrary addresses for non-hashed data. A safe way to ensure
this is by receiving a hash of the original message (which may otherwise)
be too long), and then calling toEthSignedMessageHash
on it.
→ bytes32internal
toEthSignedMessageHash(bytes32 hash)Returns an Ethereum Signed Message, created from a hash
. This
replicates the behavior of the
eth_sign
JSON-RPC method.
See recover
.
GsnTypes
GsnUtils
→ uint256internal
getChainID()→ stringinternal
getError(bytes err)→ bytes4internal
getMethodSig(bytes msgData)→ uint256internal
getParam(bytes msgData, uint256 index)→ addressinternal
getAddressParam(bytes msgData, uint256 index)→ bytes32internal
getBytes32Param(bytes msgData, uint256 index)→ bytesinternal
getBytesParam(bytes msgData, uint256 index)→ stringinternal
getStringParam(bytes msgData, uint256 index)IForwarder
getNonce(address from)
verify(struct IForwarder.ForwardRequest forwardRequest, bytes suffixData, bytes signature)
execute(struct IForwarder.ForwardRequest forwardRequest, bytes32 domainSeparator, bytes32 requestTypeHash, bytes suffixData, bytes signature)
registerRequestType(string typeName, string typeSuffix)
→ uint256external
getNonce(address from)verify(struct IForwarder.ForwardRequest forwardRequest, bytes suffixData, bytes signature)
external
→ bool,bytesexternal
execute(struct IForwarder.ForwardRequest forwardRequest, bytes32 domainSeparator, bytes32 requestTypeHash, bytes suffixData, bytes signature)registerRequestType(string typeName, string typeSuffix)
external
IPenalizer
penalizeRepeatedNonce(bytes unsignedTx1, bytes signature1, bytes unsignedTx2, bytes signature2, contract IRelayHub hub)
external
penalizeIllegalTransaction(bytes unsignedTx, bytes signature, contract IRelayHub hub)
external
→ stringexternal
versionPenalizer()IRelayHub
getStakeManager()
addRelayWorkers(address[] newRelayWorkers)
registerRelayServer(uint256 baseRelayFee, uint256 pctRelayFee, string url)
depositFor(address target)
balanceOf(address target)
withdraw(uint256 amount, address payable dest)
relayCall(struct GsnTypes.RelayRequest relayRequest, bytes signature, bytes approvalData, uint256 externalGasLimit)
penalize(address relayWorker, address payable beneficiary)
getHubOverhead()
calculateCharge(uint256 gasUsed, struct GsnTypes.RelayData relayData)
versionHub()
RelayServerRegistered(address relayManager, uint256 baseRelayFee, uint256 pctRelayFee, string relayUrl)
RelayWorkersAdded(address relayManager, address[] newRelayWorkers, uint256 workersCount)
Withdrawn(address account, address dest, uint256 amount)
Deposited(address paymaster, address from, uint256 amount)
TransactionRejectedByPaymaster(address relayManager, address paymaster, address from, address to, address relayWorker, bytes4 selector, string reason)
TransactionRelayed(address relayManager, address relayWorker, address from, address to, address paymaster, bytes4 selector, enum IRelayHub.RelayCallStatus status, uint256 charge)
Penalized(address relayWorker, address sender, uint256 reward)
→ addressexternal
getStakeManager()addRelayWorkers(address[] newRelayWorkers)
external
registerRelayServer(uint256 baseRelayFee, uint256 pctRelayFee, string url)
external
depositFor(address target)
external
→ uint256external
balanceOf(address target)withdraw(uint256 amount, address payable dest)
external
→ bool,stringexternal
relayCall(struct GsnTypes.RelayRequest relayRequest, bytes signature, bytes approvalData, uint256 externalGasLimit)penalize(address relayWorker, address payable beneficiary)
external
→ uint256external
getHubOverhead()→ uint256external
calculateCharge(uint256 gasUsed, struct GsnTypes.RelayData relayData)→ stringexternal
versionHub()RelayServerRegistered(address relayManager, uint256 baseRelayFee, uint256 pctRelayFee, string relayUrl)
RelayWorkersAdded(address relayManager, address[] newRelayWorkers, uint256 workersCount)
Withdrawn(address account, address dest, uint256 amount)
Deposited(address paymaster, address from, uint256 amount)
TransactionRejectedByPaymaster(address relayManager, address paymaster, address from, address to, address relayWorker, bytes4 selector, string reason)
TransactionRelayed(address relayManager, address relayWorker, address from, address to, address paymaster, bytes4 selector, enum IRelayHub.RelayCallStatus status, uint256 charge)
Penalized(address relayWorker, address sender, uint256 reward)
LibBytesRichErrorsV06
→ bytesinternal
InvalidByteOperationError(enum LibBytesRichErrorsV06.InvalidByteOperationErrorCodes errorCode, uint256 offset, uint256 required)LibBytesV06
rawAddress(bytes input)
contentAddress(bytes input)
memCopy(uint256 dest, uint256 source, uint256 length)
slice(bytes b, uint256 from, uint256 to)
sliceDestructive(bytes b, uint256 from, uint256 to)
popLastByte(bytes b)
equals(bytes lhs, bytes rhs)
readAddress(bytes b, uint256 index)
writeAddress(bytes b, uint256 index, address input)
readBytes32(bytes b, uint256 index)
writeBytes32(bytes b, uint256 index, bytes32 input)
readUint256(bytes b, uint256 index)
writeUint256(bytes b, uint256 index, uint256 input)
readBytes4(bytes b, uint256 index)
writeLength(bytes b, uint256 length)
→ uint256internal
rawAddress(bytes input)Gets the memory address for a byte array. @param input Byte array to lookup. @return memoryAddress Memory address of byte array. This points to the header of the byte array which contains the length.
→ uint256internal
contentAddress(bytes input)Gets the memory address for the contents of a byte array. @param input Byte array to lookup. @return memoryAddress Memory address of the contents of the byte array.
memCopy(uint256 dest, uint256 source, uint256 length)
internal
Copies length
bytes from memory location source
to dest
.
@param dest memory address to copy bytes to.
@param source memory address to copy bytes from.
@param length number of bytes to copy.
→ bytesinternal
slice(bytes b, uint256 from, uint256 to)Returns a slices from a byte array. @param b The byte array to take a slice from. @param from The starting index for the slice (inclusive). @param to The final index for the slice (exclusive). @return result The slice containing bytes at indices [from, to)
→ bytesinternal
sliceDestructive(bytes b, uint256 from, uint256 to)Returns a slice from a byte array without preserving the input.
When from == 0
, the original array will match the slice.
In other cases its state will be corrupted.
@param b The byte array to take a slice from. Will be destroyed in the process.
@param from The starting index for the slice (inclusive).
@param to The final index for the slice (exclusive).
@return result The slice containing bytes at indices [from, to)
→ bytes1internal
popLastByte(bytes b)Pops the last byte off of a byte array by modifying its length. @param b Byte array that will be modified. @return result The byte that was popped off.
→ boolinternal
equals(bytes lhs, bytes rhs)Tests equality of two byte arrays. @param lhs First byte array to compare. @param rhs Second byte array to compare. @return equal True if arrays are the same. False otherwise.
→ addressinternal
readAddress(bytes b, uint256 index)Reads an address from a position in a byte array. @param b Byte array containing an address. @param index Index in byte array of address. @return result address from byte array.
writeAddress(bytes b, uint256 index, address input)
internal
Writes an address into a specific position in a byte array. @param b Byte array to insert address into. @param index Index in byte array of address. @param input Address to put into byte array.
→ bytes32internal
readBytes32(bytes b, uint256 index)Reads a bytes32 value from a position in a byte array. @param b Byte array containing a bytes32 value. @param index Index in byte array of bytes32 value. @return result bytes32 value from byte array.
writeBytes32(bytes b, uint256 index, bytes32 input)
internal
Writes a bytes32 into a specific position in a byte array. @param b Byte array to insert <input> into. @param index Index in byte array of <input>. @param input bytes32 to put into byte array.
→ uint256internal
readUint256(bytes b, uint256 index)Reads a uint256 value from a position in a byte array. @param b Byte array containing a uint256 value. @param index Index in byte array of uint256 value. @return result uint256 value from byte array.
writeUint256(bytes b, uint256 index, uint256 input)
internal
Writes a uint256 into a specific position in a byte array. @param b Byte array to insert <input> into. @param index Index in byte array of <input>. @param input uint256 to put into byte array.
→ bytes4internal
readBytes4(bytes b, uint256 index)Reads an unpadded bytes4 value from a position in a byte array. @param b Byte array containing a bytes4 value. @param index Index in byte array of bytes4 value. @return result bytes4 value from byte array.
writeLength(bytes b, uint256 length)
internal
Writes a new length to a byte array. Decreasing length will lead to removing the corresponding lower order bytes from the byte array. Increasing length may lead to appending adjacent in-memory bytes to the end of the byte array. @param b Bytes array to write new length to. @param length New length of byte array.
LibRichErrorsV06
→ bytesinternal
StandardError(string message)ABI encode a standard, string revert error payload.
This is the same payload that would be included by a revert(string)
solidity statement. It has the function signature Error(string)
.
@param message The error string.
@return The ABI encoded error.
rrevert(bytes errorData)
internal
Reverts an encoded rich revert reason errorData
.
@param errorData ABI encoded error data.
Penalizer
penalizeRepeatedNonce(bytes unsignedTx1, bytes signature1, bytes unsignedTx2, bytes signature2, contract IRelayHub hub)
public
penalizeIllegalTransaction(bytes unsignedTx, bytes signature, contract IRelayHub hub)
public
RLPReader
decodeTransaction(bytes rawTransaction)
toRlpItem(bytes item)
toList(struct RLPReader.RLPItem item)
isList(struct RLPReader.RLPItem item)
numItems(struct RLPReader.RLPItem item)
_itemLength(uint256 memPtr)
_payloadOffset(uint256 memPtr)
toRlpBytes(struct RLPReader.RLPItem item)
toBoolean(struct RLPReader.RLPItem item)
toAddress(struct RLPReader.RLPItem item)
toUint(struct RLPReader.RLPItem item)
toBytes(struct RLPReader.RLPItem item)
copy(uint256 src, uint256 dest, uint256 len)
→ uint256,uint256,uint256,address,uint256,bytesinternal
decodeTransaction(bytes rawTransaction)→ struct RLPReader.RLPIteminternal
toRlpItem(bytes item)→ struct RLPReader.RLPItem[]internal
toList(struct RLPReader.RLPItem item)→ boolinternal
isList(struct RLPReader.RLPItem item)→ uint256internal
numItems(struct RLPReader.RLPItem item)→ uint256internal
_itemLength(uint256 memPtr)→ uint256internal
_payloadOffset(uint256 memPtr)→ bytesinternal
toRlpBytes(struct RLPReader.RLPItem item)→ boolinternal
toBoolean(struct RLPReader.RLPItem item)→ addressinternal
toAddress(struct RLPReader.RLPItem item)→ uint256internal
toUint(struct RLPReader.RLPItem item)→ bytesinternal
toBytes(struct RLPReader.RLPItem item)copy(uint256 src, uint256 dest, uint256 len)
internal
BaseRelayRecipient
→ boolpublic
isTrustedForwarder(address forwarder)→ address payableinternal
_msgSender()Forwarder
fallback()
getNonce(address from)
constructor()
verify(struct IForwarder.ForwardRequest req, bytes suffixData, bytes sig)
execute(struct IForwarder.ForwardRequest req, bytes32 domainSeparator, bytes32 requestTypeHash, bytes suffixData, bytes sig)
_verifyNonce(struct IForwarder.ForwardRequest req)
_updateNonce(struct IForwarder.ForwardRequest req)
registerRequestType(string typeName, string typeSuffix)
registerRequestTypeInternal(string requestType)
getRelayMessageHash(struct GsnTypes.RelayRequest req)
_getEncoded(struct IForwarder.ForwardRequest relayRequest, bytes suffixData)
_verifySig(struct IForwarder.ForwardRequest req, bytes suffixData, bytes sig)
fallback()
external
→ uint256public
getNonce(address from)constructor()
public
verify(struct IForwarder.ForwardRequest req, bytes suffixData, bytes sig)
public
→ bool,bytespublic
execute(struct IForwarder.ForwardRequest req, bytes32 domainSeparator, bytes32 requestTypeHash, bytes suffixData, bytes sig)_verifyNonce(struct IForwarder.ForwardRequest req)
internal
_updateNonce(struct IForwarder.ForwardRequest req)
internal
registerRequestType(string typeName, string typeSuffix)
external
registerRequestTypeInternal(string requestType)
internal
→ bytes32public
getRelayMessageHash(struct GsnTypes.RelayRequest req)→ bytes32internal
_getEncoded(struct IForwarder.ForwardRequest relayRequest, bytes suffixData)_verifySig(struct IForwarder.ForwardRequest req, bytes suffixData, bytes sig)
public
RequestTypeRegistered(bytes32 typeHash, string typeStr)
GsnEip712Library
splitRequest(struct GsnTypes.RelayRequest req)
verifyForwarderTrusted(struct GsnTypes.RelayRequest relayRequest)
verifySignature(struct GsnTypes.RelayRequest relayRequest, bytes signature)
verify(struct GsnTypes.RelayRequest relayRequest, bytes signature)
execute(struct GsnTypes.RelayRequest relayRequest, bytes signature)
domainSeparator(address forwarder)
getChainID()
hashDomain(struct GsnEip712Library.EIP712Domain req)
hashRelayData(struct GsnTypes.RelayData req)
hash(struct IForwarder.ForwardRequest req)
→ struct IForwarder.ForwardRequest,bytesinternal
splitRequest(struct GsnTypes.RelayRequest req)verifyForwarderTrusted(struct GsnTypes.RelayRequest relayRequest)
internal
verifySignature(struct GsnTypes.RelayRequest relayRequest, bytes signature)
internal
verify(struct GsnTypes.RelayRequest relayRequest, bytes signature)
internal
→ bool,stringinternal
execute(struct GsnTypes.RelayRequest relayRequest, bytes signature)→ bytes32internal
domainSeparator(address forwarder)→ uint256internal
getChainID()→ bytes32internal
hashDomain(struct GsnEip712Library.EIP712Domain req)→ bytes32internal
hashRelayData(struct GsnTypes.RelayData req)→ bytes32internal
hash(struct IForwarder.ForwardRequest req)IPaymaster
getHubAddr()
getRelayHubDeposit()
getGasLimits()
acceptRelayedCall(struct GsnTypes.RelayRequest relayRequest, bytes signature, bytes approvalData, uint256 maxPossibleGas)
preRelayedCall(bytes context)
postRelayedCall(bytes context, bool success, bytes32 preRetVal, uint256 gasUseWithoutPost, struct GsnTypes.RelayData relayData)
versionPaymaster()
→ addressexternal
getHubAddr()→ uint256external
getRelayHubDeposit()→ struct IPaymaster.GasLimitsexternal
getGasLimits()→ bytesexternal
acceptRelayedCall(struct GsnTypes.RelayRequest relayRequest, bytes signature, bytes approvalData, uint256 maxPossibleGas)→ bytes32external
preRelayedCall(bytes context)postRelayedCall(bytes context, bool success, bytes32 preRetVal, uint256 gasUseWithoutPost, struct GsnTypes.RelayData relayData)
external
→ stringexternal
versionPaymaster()IRelayRecipient
→ boolpublic
isTrustedForwarder(address forwarder)→ address payableinternal
_msgSender()→ stringexternal
versionRecipient()ISignatureVerifier
→ boolexternal
verify(struct ISignatureVerifier.RelayRequest req, bytes signature)→ stringexternal
versionSM()IStakeManager
stakeForAddress(address relayManager, uint256 unstakeDelay)
unlockStake(address relayManager)
withdrawStake(address relayManager)
authorizeHubByOwner(address relayManager, address relayHub)
authorizeHubByManager(address relayHub)
unauthorizeHubByOwner(address relayManager, address relayHub)
unauthorizeHubByManager(address relayHub)
isRelayManagerStaked(address relayManager, uint256 minAmount, uint256 minUnstakeDelay)
penalizeRelayManager(address relayManager, address payable beneficiary, uint256 amount)
getStakeInfo(address relayManager)
versionSM()
StakeAdded(address relayManager, address owner, uint256 stake, uint256 unstakeDelay)
StakeUnlocked(address relayManager, address owner, uint256 withdrawBlock)
StakeWithdrawn(address relayManager, address owner, uint256 amount)
StakePenalized(address relayManager, address beneficiary, uint256 reward)
HubAuthorized(address relayManager, address relayHub)
HubUnauthorized(address relayManager, address relayHub, uint256 removalBlock)
stakeForAddress(address relayManager, uint256 unstakeDelay)
external
unlockStake(address relayManager)
external
withdrawStake(address relayManager)
external
authorizeHubByOwner(address relayManager, address relayHub)
external
authorizeHubByManager(address relayHub)
external
unauthorizeHubByOwner(address relayManager, address relayHub)
external
unauthorizeHubByManager(address relayHub)
external
→ boolexternal
isRelayManagerStaked(address relayManager, uint256 minAmount, uint256 minUnstakeDelay)penalizeRelayManager(address relayManager, address payable beneficiary, uint256 amount)
external
→ struct IStakeManager.StakeInfoexternal
getStakeInfo(address relayManager)→ stringexternal
versionSM()StakeAdded(address relayManager, address owner, uint256 stake, uint256 unstakeDelay)
StakeUnlocked(address relayManager, address owner, uint256 withdrawBlock)
StakeWithdrawn(address relayManager, address owner, uint256 amount)
StakePenalized(address relayManager, address beneficiary, uint256 reward)
HubAuthorized(address relayManager, address relayHub)
HubUnauthorized(address relayManager, address relayHub, uint256 removalBlock)
RelayHubV2
getHubOverhead()
constructor(contract StakeManager _stakeManager, contract Penalizer _penalizer)
getStakeManager()
registerRelayServer(uint256 baseRelayFee, uint256 pctRelayFee, string url)
addRelayWorkers(address[] newRelayWorkers)
depositFor(address target)
balanceOf(address target)
withdraw(uint256 amount, address payable dest)
canRelay(struct GsnTypes.RelayRequest relayRequest, uint256 initialGas, bytes signature, bytes approvalData)
relayCall(struct GsnTypes.RelayRequest relayRequest, bytes signature, bytes approvalData, uint256 externalGasLimit)
innerRelayCall(struct GsnTypes.RelayRequest relayRequest, bytes signature, struct IPaymaster.GasLimits gasLimits, uint256 totalInitialGas, bytes recipientContext)
calculateCharge(uint256 gasUsed, struct GsnTypes.RelayData relayData)
penalize(address relayWorker, address payable beneficiary)
versionHub()
RelayServerRegistered(address relayManager, uint256 baseRelayFee, uint256 pctRelayFee, string relayUrl)
RelayWorkersAdded(address relayManager, address[] newRelayWorkers, uint256 workersCount)
Withdrawn(address account, address dest, uint256 amount)
Deposited(address paymaster, address from, uint256 amount)
TransactionRejectedByPaymaster(address relayManager, address paymaster, address from, address to, address relayWorker, bytes4 selector, string reason)
TransactionRelayed(address relayManager, address relayWorker, address from, address to, address paymaster, bytes4 selector, enum IRelayHub.RelayCallStatus status, uint256 charge)
Penalized(address relayWorker, address sender, uint256 reward)
→ uint256external
getHubOverhead()constructor(contract StakeManager _stakeManager, contract Penalizer _penalizer)
public
→ addressexternal
getStakeManager()registerRelayServer(uint256 baseRelayFee, uint256 pctRelayFee, string url)
public
addRelayWorkers(address[] newRelayWorkers)
public
depositFor(address target)
public
→ uint256external
balanceOf(address target)withdraw(uint256 amount, address payable dest)
public
→ bool,bytes,struct IPaymaster.GasLimitspublic
canRelay(struct GsnTypes.RelayRequest relayRequest, uint256 initialGas, bytes signature, bytes approvalData)→ bool,stringpublic
relayCall(struct GsnTypes.RelayRequest relayRequest, bytes signature, bytes approvalData, uint256 externalGasLimit)→ enum IRelayHub.RelayCallStatuspublic
innerRelayCall(struct GsnTypes.RelayRequest relayRequest, bytes signature, struct IPaymaster.GasLimits gasLimits, uint256 totalInitialGas, bytes recipientContext)→ uint256public
calculateCharge(uint256 gasUsed, struct GsnTypes.RelayData relayData)penalize(address relayWorker, address payable beneficiary)
external
SafeMath
→ uint256internal
add(uint256 a, uint256 b)Returns the addition of two unsigned integers, reverting on overflow.
Counterpart to Solidity's +
operator.
Requirements:
- Addition cannot overflow.
→ uint256internal
sub(uint256 a, uint256 b)Returns the subtraction of two unsigned integers, reverting on overflow (when the result is negative).
Counterpart to Solidity's -
operator.
Requirements:
- Subtraction cannot overflow.
→ uint256internal
mul(uint256 a, uint256 b)Returns the multiplication of two unsigned integers, reverting on overflow.
Counterpart to Solidity's *
operator.
Requirements:
- Multiplication cannot overflow.
→ uint256internal
div(uint256 a, uint256 b)Returns the integer division of two unsigned integers. Reverts on division by zero. The result is rounded towards zero.
Counterpart to Solidity's /
operator. Note: this function uses a
revert
opcode (which leaves remaining gas untouched) while Solidity
uses an invalid opcode to revert (consuming all remaining gas).
Requirements:
- The divisor cannot be zero.
→ uint256internal
mod(uint256 a, uint256 b)Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), Reverts when dividing by zero.
Counterpart to Solidity's %
operator. This function uses a revert
opcode (which leaves remaining gas untouched) while Solidity uses an
invalid opcode to revert (consuming all remaining gas).
Requirements:
- The divisor cannot be zero.
StakeManager
getStakeInfo(address relayManager)
stakeForAddress(address relayManager, uint256 unstakeDelay)
unlockStake(address relayManager)
withdrawStake(address relayManager)
authorizeHubByOwner(address relayManager, address relayHub)
authorizeHubByManager(address relayHub)
_authorizeHub(address relayManager, address relayHub)
unauthorizeHubByOwner(address relayManager, address relayHub)
unauthorizeHubByManager(address relayHub)
_unauthorizeHub(address relayManager, address relayHub)
isRelayManagerStaked(address relayManager, uint256 minAmount, uint256 minUnstakeDelay)
penalizeRelayManager(address relayManager, address payable beneficiary, uint256 amount)
versionSM()
StakeAdded(address relayManager, address owner, uint256 stake, uint256 unstakeDelay)
StakeUnlocked(address relayManager, address owner, uint256 withdrawBlock)
StakeWithdrawn(address relayManager, address owner, uint256 amount)
StakePenalized(address relayManager, address beneficiary, uint256 reward)
HubAuthorized(address relayManager, address relayHub)
HubUnauthorized(address relayManager, address relayHub, uint256 removalBlock)