> For the complete documentation index, see [llms.txt](https://docs.metalex.tech/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.metalex.tech/protocol-how-to-guides/sign-a-cyberagreement.md).

# Sign a cyberAgreement

**cyberSign** is the protocol's agreement layer: the `CyberAgreementRegistry` holds agreement **templates** and executed, multi-party-signed **contracts**. Deals and rounds reference it for their underlying agreements.

## 1. Register a template

A template is a reusable legal document with a field schema. Template creation is **permissionless** — anyone can register one; ids are first-come (`TemplateAlreadyExists` on a collision).

```solidity
ICyberAgreementRegistry(registry).createTemplate(
    templateId,        // bytes32 — chosen id
    "Series A Stockholder Consent v1",  // title
    "ipfs://...",      // legalContractUri (canonical text)
    globalFields,      // string[] — fields common to the contract
    partyFields        // string[] — fields filled per signing party
);
```

For one-off agreements you can skip the separate template step: `createStandaloneContractAndSign(title, legalContractUri, globalFields, partyFields, salt, globalValues, parties, partyValues, expiry, signature)` derives a template id from the content, creates the template just-in-time if needed, creates the contract, and records the proposer's signature — all in one transaction.

## 2. Create a contract from the template

```solidity
bytes32 contractId = ICyberAgreementRegistry(registry).createContract(
    templateId,
    salt,           // uint256
    globalValues,   // string[]
    parties,        // address[]
    partyValues,    // string[][] — per-party values
    secretHash,     // bytes32
    finalizer,      // address allowed to finalise
    expiry          // uint256
);
```

## 3. Parties sign

Each party signs. Every entry point carries the signer's EIP-712 signature over the agreement content (contract id, canonical text URI, fields and values):

* `signContract(contractId, partyValues, signature, fillUnallocated, secret)` — the caller signs for itself.
* `signContractFor(signer, contractId, partyValues, signature, fillUnallocated, secret)` — relayed, with the signer's EIP-712 signature.
* `signContractWithEscrow(escrowSigner, contractId, partyValues, signature, fillUnallocated, secret)` — using a pre-escrowed signature; only callable by the contract's finalizer, which must be a defined smart contract (e.g. a DealManager).

When every party has signed, the registry emits `ContractFullySigned`.

A party can also delegate signing authority with `setDelegation(delegate, expiry)` / `revokeDelegation()`.

## 4. Finalise

If the contract was created with `finalizer == address(0)`, it finalizes automatically when the last party signs. Otherwise the finalizer calls:

```solidity
ICyberAgreementRegistry(registry).finalizeContract(contractId);
```

## Voiding

`voidContractFor(contractId, party, signature)` records a party's void request (EIP-712-signed, or submitted by the finalizer). The contract voids when every allocated party requests it (unfilled open slots don't count toward unanimity), when its nonzero expiry has passed, or when the first party requests it while only one signature has been collected.

{% hint style="info" %}
An agreement created with `expiry == 0` has **no deadline**: it never counts as expired, so it voids only by unanimous request (or by the proposer while it is the only signer). With a nonzero expiry, unanimous-void semantics hold only **until that expiry passes** — an unfinalized agreement past its expiry is voidable by a single party's request.
{% endhint %}

## Checking status

`hasSigned`, `allPartiesSigned`, `isFinalized`, `isVoided`, `getContractDetails`, `getAgreementsForParty`.

## Related

* [CyberAgreementRegistry](/protocol-reference/contracts/cyberagreementregistry.md), [Agreement templates](/protocol-reference/templates.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.metalex.tech/protocol-how-to-guides/sign-a-cyberagreement.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
