World
Reference
World context

WorldContextConsumer

Git Source (opens in a new tab)

Inherits: IWorldContextConsumer

This contract is designed to extract trusted context values (like msg.sender and msg.value) from the appended calldata. It provides mechanisms similar to EIP-2771 (https://eips.ethereum.org/EIPS/eip-2771 (opens in a new tab)), but allowing any contract to be the trusted forwarder.

This contract should only be used for contracts without their own storage, like Systems.

Functions

_msgSender

Extract the msg.sender from the context appended to the calldata.

function _msgSender() public view returns (address sender);

Returns

NameTypeDescription
senderaddressThe msg.sender in the call to the World contract before the World routed the call to the WorldContextConsumer contract.

_msgValue

Extract the msg.value from the context appended to the calldata.

function _msgValue() public pure returns (uint256 value);

Returns

NameTypeDescription
valueuint256The msg.value in the call to the World contract before the World routed the call to the WorldContextConsumer contract.

_world

Get the address of the World contract that routed the call to this WorldContextConsumer.

function _world() public view returns (address);

Returns

NameTypeDescription
<none>addressThe address of the World contract that routed the call to this WorldContextConsumer.

supportsInterface

Checks if an interface is supported by the contract. using ERC-165 supportsInterface (see https://eips.ethereum.org/EIPS/eip-165 (opens in a new tab))

function supportsInterface(bytes4 interfaceId) public pure virtual returns (bool);

Parameters

NameTypeDescription
interfaceIdbytes4The ID of the interface in question.

Returns

NameTypeDescription
<none>boolTrue if the interface is supported, false otherwise.

WorldContext.sol constants

Git Source (opens in a new tab)

CONTEXT_BYTES

uint256 constant CONTEXT_BYTES = 20 + 32;

WorldContextConsumerLib

Git Source (opens in a new tab)

Functions

_msgSender

Extract the msg.sender from the context appended to the calldata.

function _msgSender() internal view returns (address sender);

Returns

NameTypeDescription
senderaddressThe msg.sender in the call to the World contract before the World routed the call to the WorldContextConsumer contract.

_msgValue

Extract the msg.value from the context appended to the calldata.

function _msgValue() internal pure returns (uint256 value);

Returns

NameTypeDescription
valueuint256The msg.value in the call to the World contract before the World routed the call to the WorldContextConsumer contract.

_world

Get the address of the World contract that routed the call to this WorldContextConsumer.

function _world() internal view returns (address);

Returns

NameTypeDescription
<none>addressThe address of the World contract that routed the call to this WorldContextConsumer.

WorldContextProviderLib

Git Source (opens in a new tab)

This library provides functions to make calls or delegatecalls to other contracts, appending the context values (like msg.sender and msg.value) to the calldata for WorldContextConsumer to consume.

Functions

appendContext

Appends context values to the given calldata.

function appendContext(bytes memory callData, address msgSender, uint256 msgValue) internal pure returns (bytes memory);

Parameters

NameTypeDescription
callDatabytesThe original calldata.
msgSenderaddressThe address of the transaction sender.
msgValueuint256The amount of ether sent with the original transaction.

Returns

NameTypeDescription
<none>bytesThe new calldata with context values appended.

callWithContext

Makes a call to the target contract with context values appended to the calldata.

function callWithContext(
  address msgSender,
  uint256 msgValue,
  address target,
  bytes memory callData
) internal returns (bool success, bytes memory data);

Parameters

NameTypeDescription
msgSenderaddressThe address of the transaction sender.
msgValueuint256The amount of ether sent with the original transaction.
targetaddressThe address of the contract to call.
callDatabytesThe calldata for the call.

Returns

NameTypeDescription
successboolA boolean indicating whether the call was successful or not.
databytesThe abi encoded return data from the call.

delegatecallWithContext

Makes a delegatecall to the target contract with context values appended to the calldata.

function delegatecallWithContext(
  address msgSender,
  uint256 msgValue,
  address target,
  bytes memory callData
) internal returns (bool success, bytes memory data);

Parameters

NameTypeDescription
msgSenderaddressThe address of the transaction sender.
msgValueuint256The amount of ether sent with the original transaction.
targetaddressThe address of the contract to call.
callDatabytesThe calldata for the call.

Returns

NameTypeDescription
successboolA boolean indicating whether the call was successful or not.
databytesThe abi encoded return data from the call.

callWithContextOrRevert

Makes a call to the target contract with context values appended to the calldata.

Revert in the case of failure.

function callWithContextOrRevert(
  address msgSender,
  uint256 msgValue,
  address target,
  bytes memory callData
) internal returns (bytes memory data);

Parameters

NameTypeDescription
msgSenderaddressThe address of the transaction sender.
msgValueuint256The amount of ether sent with the original transaction.
targetaddressThe address of the contract to call.
callDatabytesThe calldata for the call.

Returns

NameTypeDescription
databytesThe abi encoded return data from the call.

delegatecallWithContextOrRevert

Makes a delegatecall to the target contract with context values appended to the calldata.

Revert in the case of failure.

function delegatecallWithContextOrRevert(
  address msgSender,
  uint256 msgValue,
  address target,
  bytes memory callData
) internal returns (bytes memory data);

Parameters

NameTypeDescription
msgSenderaddressThe address of the transaction sender.
msgValueuint256The amount of ether sent with the original transaction.
targetaddressThe address of the contract to call.
callDatabytesThe calldata for the call.

Returns

NameTypeDescription
databytesThe abi encoded return data from the call.