> For the complete documentation index, see [llms.txt](https://elektro.gitbook.io/elektro-protocol/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://elektro.gitbook.io/elektro-protocol/smart-contracts/natspec-technical-documentation/proxy-pattern-base-logic/router.md).

# Router

View Source: @nomisma/elektro-protocol-aux/contracts/delegate/Router.sol

**↗ Extends:** [**RoleAware**](broken://pages/4CPDKP7TOxZRZFoND8ho) **↘ Derived Contracts: ElektroEventEmitterRouter, ElektroRegistryRouter, ElektroRouter, FundLockRouter,** [**TokenManagerRouter**](broken://pages/9cczOHlzAdmUbpglnG20)

**Router**

Contracts that extend {Router} contract serves as data storage. {Router} delegates all calls based on mapping found in Resolver. All calls are executed in context of calling router and for every functionality/proxy modules, Router's address is being used as an entry point and represents functionality of the module (full module's ABI is tied to the respective Router's address). This contract is not being deployed, but inherited by specific Router contracts of each module.

> IMPORTANT: A signature for any external or public function added to this contract needs to be present in Resolver contract as a constant and be checked against during `register()` process. {Router} functions can NOT be shadowed by any other contracts!

## Contract Members

**Constants & Variables**

```js
bytes32 private constant GOVERNOR_ROLE_NAME;
```

***

```js
contract Resolver public resolver;
```

***

## Functions

* ()
* ()
* setResolver(address \_resolver)
* initRouter(address \_resolver, address \_roleManager)

###

Default fallback functions that intercepts/accepts all calls. Method signature found in Resolver is used to get address of contract to call. Next `delegatecall` is executed to call resolved contract address.

> IMPORTANT: This function gets called ONLY when no functions with the needed name are present in this contract!

```js
function () external payable
```

**Arguments**

###

```js
function () external payable
```

**Arguments**

### setResolver

Setting {Resolver} contract used for routing calls. This address is one of the main key points of each Router contract, since this address will be used to figure out where to route calls for each module.

> IMPORTANT! This function should not exist on implementation interfaces or implementation logic contracts! This would cause a potential shadowing problem that might arise. We should ONLY call this function on a particular {Router} contract DIRECTLY, and not through an implementation interface it is used with!

```js
function setResolver(address _resolver) public nonpayable onlyRole 
```

**Arguments**

| Name       | Type    | Description                                           |
| ---------- | ------- | ----------------------------------------------------- |
| \_resolver | address | address of {Resolver} contract to be set for {Router} |

### initRouter

{Router} initialization function that sets resolver and governance role

```js
function initRouter(address _resolver, address _roleManager) internal nonpayable
```

**Arguments**

| Name          | Type    | Description                                           |
| ------------- | ------- | ----------------------------------------------------- |
| \_resolver    | address | address of {Resolver} contract to be set for {Router} |
| \_roleManager | address |                                                       |
