# rollup.emitDelegateCallVoucher

Emits a **delegate-call voucher** — like a [voucher](/cmio/reference/emit-voucher), but executed with `DELEGATECALL`: the destination's code runs in the application contract's own storage context, address and balance. An advanced primitive for library-style execution and upgrade patterns; with great power comes great responsibility over the application contract's state.

Encoded on-chain as `DelegateCallVoucher(address,bytes)` and added to the outputs merkle tree (provable).

## Usage

```ts twoslash
import { Rollup } from '@deroll/cmio';
const rollup = new Rollup();
declare const calldata: Uint8Array;
// ---cut---
const index = rollup.emitDelegateCallVoucher({
    destination: '0x5FbDB2315678afecb367f032d93F642f64180aa3', // library contract
    payload: calldata,
});
```

## Returns

`number` — the output index among all provable outputs ever emitted by the application.

## Parameters

### destination

* Type: `AddressLike` — 0x-prefixed hex string, `Buffer` or `Uint8Array`
* Required; must be exactly 20 bytes

The contract whose code will run in the application contract's context.

### payload

* Type: `BytesLike` — 0x-prefixed hex string, `Buffer` or `Uint8Array`
* Default: empty

Calldata for the delegate call. There is no `value` parameter — `DELEGATECALL` cannot transfer ether.

## Errors

| Condition | Error |
| --- | --- |
| `destination` not 20 bytes / malformed hex | `TypeError` |
| Output larger than the machine's output buffer | `RollupError` with negative `errno` |
