> For the complete documentation index, see [llms.txt](https://gabriel-j-shapiro.gitbook.io/metalex-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gabriel-j-shapiro.gitbook.io/metalex-docs/protocol-tutorials/scripify-and-settle.md).

# Scripify and settle a secondary trade

In this tutorial you make part of a cyberCERT tradable as fungible **cyberSCRIP**, transfer it to a buyer, and convert it back into a cyberCERT.

> Code is **illustrative of the flow** and uses the real signatures from `cybercorps-contracts` (`develop`).

## Prerequisites

A cyberCERT from [Tutorial 1](/metalex-docs/protocol-tutorials/incorporate-a-cybercorp.md) — say `tokenId = 1` on the Common Stock printer at `commonPrinter`, held by `alice`. You also need the `issuanceManager` address.

## 1. Deploy a CyberScrip for the printer

A CyberScrip is deployed per CyberCertPrinter via `deployCyberScrip`. This is also where you set the scrip ratio, conversion conditions, and which compliance powers exist.

```solidity
address cyberScrip = IIssuanceManager(issuanceManager).deployCyberScrip(
    commonPrinter,
    typeRestrictionHooks,   // ITransferRestrictionHook[]
    certToScripConditions,  // ICondition[] gating scripification
    scripToCertConditions,  // ICondition[] gating de-scripification
    1e18,                   // scripToCertMinimum
    1,                      // scripRatioNumerator
    1,                      // scripRatioDenominator
    new uint256[](0),       // scripifyWhitelistIds
    false,                  // scripifyWhitelistEnabled
    true,                   // enableForceTransfer
    true,                   // enableForceBurn
    true                    // enableFreeze
);
```

## 2. Scripify part of the cert

```solidity
IIssuanceManager(issuanceManager).scripifyCert(
    commonPrinter,   // certAddress
    1,               // id (the cyberCERT token id)
    1_000_000,       // amount of units to scripify
    alice            // recipient of the cyberSCRIP
);
```

This reduces the cert's `unitsRepresented`, records the scripified units in the scrip pool, and mints cyberSCRIP to Alice (scaled by the scrip ratio). The cyberSCRIP is the *same security in fungible form* — see [the dual-token model](/metalex-docs/protocol-explanation/dual-token-model.md).

## 3. Sell the scrip

```solidity
CyberScrip(cyberScrip).transfer(bob, 1_000_000e18);
```

If a transfer hook is installed, the transfer must satisfy it (see [Restrict cyberSCRIP transfers](/metalex-docs/protocol-how-to-guides/restrict-transfers.md)).

## 4. (New holder) issuer pre-approves recertification

Because Bob is not yet a registered holder, an officer pre-sets the certificate metadata he will receive on de-scripification:

```solidity
IIssuanceManager(issuanceManager).setRecertificationApproval(
    commonPrinter,
    bob,
    "Bob Buyer",
    bobCertDetails,    // CertificateDetails
    officerSignature   // bytes
);
```

## 5. Convert scrip back to a cyberCERT

```solidity
IIssuanceManager(issuanceManager).convertScripToCert(
    commonPrinter,   // certAddress
    1_000_000e18     // amount of cyberSCRIP to present
);
```

This burns Bob's cyberSCRIP, withdraws the units from the scrip pool, and — using the approved metadata — puts Bob on the register. An `IssuerApprovalRecertificationCondition` among the `scripToCertConditions` is what enforces the approval requirement for new holders.

## What you just did

* Deployed a cyberSCRIP and scripified part of a cyberCERT.
* Traded the security in fungible form.
* Recertified a new holder back onto the register, under issuer approval.

## Next

* How-to: [Restrict cyberSCRIP transfers](/metalex-docs/protocol-how-to-guides/restrict-transfers.md).
* Reference: [CyberScrip](/metalex-docs/protocol-reference/contracts/cyberscrip.md), [IssuanceManager](/metalex-docs/protocol-reference/contracts/issuancemanager.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://gabriel-j-shapiro.gitbook.io/metalex-docs/protocol-tutorials/scripify-and-settle.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.
