# Proxyable¶

## Description¶

This contract is designed to operate in tandem with Proxy. In fact, in order to function properly, every contract operating behind a CALL-style proxy must inherit Proxyable to ensure that the message sender is set and that events are correctly emitted.

This contract can support two proxies simultaneously. Events can be emitted independently from each proxy, but it is sensible to restrict event emission to a single proxy in most cases.

Source: contracts/Proxyable.sol

## Variables¶

### messageSender¶

Source

The caller of the proxy in the current invocation. This variable is set to the value of msg.sender visible to the proxy before every function call by that Proxy to this Proxyable. Once set, messageSender should be used in place of msg.sender wherever it is used in contracts inheriting Proxyable.

All functions which make use of messageSender should have one of the modifiers provided by the Proxyable interface, otherwise users who call the contract directly rather than through the proxy will be executing with stale values of messageSender.

Functions which do not require messageSender need not apply any of the proxy modifiers, but care must be taken when applying other function modifiers within a proxyable contract. For example, see optionalProxy_onlyOwner.

Type: address

### proxy¶

Source

The address of the main proxy that this contract operates underneath. It is this address that events should be emitted from using Proxy._emit.

Type: contract Proxy

## Constructor¶

### constructor¶

Source

Initialises this contract's proxy and the inherited Owned instance.

Details

Signature

constructor(address payable _proxy)

Visibility

internal

State Mutability



Requires

Emits

## Restricted Functions¶

### setMessageSender¶

Source

This is used by proxies to set messageSender before forwarding a function call. This is only callable by the proxy or integrationProxy.

Details

Signature

setMessageSender(address sender)

Visibility

external

State Mutability



Modifiers

### setProxy¶

Source

Sets this contract's primary proxy. setProxy cannot be called through a proxy.

Details

Signature

setProxy(address payable _proxy)

Visibility

external

State Mutability



Modifiers

Emits

## Modifiers¶

### onlyProxy¶

Source

Reverts the transaction if the actual msg.sender (not messageSender) is not the proxy or the integration proxy.

### optionalProxy¶

Source

This modifier allows a function to be called through the proxies, or alternatively to be called directly for a small gas savings.

It operates simply: if the caller is not either the proxy or the integration proxy, then overwrite messageSender with msg.sender, otherwise use whatever it was set to by the proxy.

### optionalProxy_onlyOwner¶

Source

This modifier is largely the same as optionalProxy, but it disallow callers who are not the contract owner. This modifier exists because Owned.onlyOwner checks msg.sender, and not messageSender.

## Events¶

### ProxyUpdated¶

Source

proxyAddress has been set as the new proxy.

Signature: ProxyUpdated(address proxyAddress)