Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

🔐Tokenization API

Overview

The Tokenization API enables developers to generate Lab (OCL) membership agreements and tokenize Labs into IP Tokens (IPTs) on Base. It combines offchain GraphQL mutations with onchain blockchain transactions to create legally-bound, tradeable research assets.

Capabilities:

  • Generate Lab (OCL) membership agreements

  • Tokenize Labs into IP Tokens (IPTs) on Base

  • Manage the complete tokenization lifecycle

  • Integrate with smart contracts via viem/ethers


Authentication

All Tokenization API mutations require a consumer credential.

Obtaining a Consumer Credential

The consumer credential is the same one every Molecule API uses — if you already have one, you are ready. If not, create one on the API credentials page of the Labs app; see Getting Started.

Using Your Consumer Credential

Include the consumer credential in all requests using the Authorization header, with no Bearer prefix:


API Endpoint


OCL Membership Agreement

Generate the membership agreement for an onchain lab (OCL) — the terms document an IP Token holder accepts when the Lab is tokenized. It returns an agreementKey (an S3 object key) paired with a SHA-256 agreementContentHash that binds the signature to the exact document.

generateOclMembershipAgreement

Input:

  • agreementData (AWSJSON): Stringified object with the fields below.

Required Fields in agreementData:

Generates the OCL membership agreement document for a Lab token and stores it in the public OCL agreements bucket. The returned agreementKey and agreementContentHash are the inputs to getOclTermsMessage. Fails with INVALID_METADATA when agreementData is not valid JSON, INVALID_INPUT when it fails validation or oclId is malformed, and INTERNAL_ERROR (retryable) when generation or storage fails.

Returns GenerateOclMembershipAgreementResult!.

Name
Type
Description

agreementData

AWSJSON!

JSON object with oclId (32-byte OCL id as 0x plus 64 hex, any case), symbol (ticker, 1-20 alphanumeric characters) and optionally title (display name). Any other key is rejected.

Response:

Example Request:

The returned agreementKey and agreementContentHash are consumed by the getOclTermsMessage(agreementKey, contentHash, labId, chainId) query to produce the message the member signs.


Lab (OCL) Tokenization Workflow

Labs are tokenized on Base through the OclTokenizer contract. It mints one fractional ERC-20 IP Token (IPT) per Lab — deployed as a LabToken contract — gated by a signed membership agreement.

High-Level Flow

The terms message is reconstructed onchain by OclTermsPermissioner.specificTermsV1() — the backend's getOclTermsMessage returns byte-identical text, so always sign exactly the string the API returns.

OclTokenizer Contract Functions

tokenize():

  • Creates the Lab's ERC-20 IP Token

  • Parameters:

    • labId (uint256): The LabNFT token ID

    • amount (uint256): Initial supply issued to the caller (in wei)

    • symbol (string): Token ticker symbol — the name is derived automatically as Lab Tokens of Lab #<labId>

    • s3Key (string): agreementKey from Step 1

    • contentHash (bytes32): agreementContentHash from Step 1

    • signature (bytes): Signed terms from Step 3

  • Caller must be the Lab's controller (the current LabNFT owner); reverts MustControlLab() otherwise

  • One token per Lab — a second call reverts AlreadyTokenized()

attachToken():

  • "Bring your own token": wraps a pre-existing ERC-20 (≤ 18 decimals) in a read-only WrappedLabToken carrying the Lab's metadata instead of minting a new one

  • Parameters: labId, s3Key, contentHash, signature, tokenContract

issue() / cap():

  • issue(labToken, amount, receiver) — mint additional supply; controller-only

  • cap(labToken) — permanently freeze issuance; controller-only, irreversible

Networks (Lab Tokenization)

Network
Chain ID
OclTokenizer (proxy)

Base Mainnet

8453

0x62F532C3f563D974deEc103AAb8cC597f4f9c84E

Base Sepolia (sandbox)

84532

0x70F9A9E28C58f78049768F503CCd90E6f6e26BcD


Requirements

For Lab Tokenization

  • Consumer credential: the same credential every Molecule API uses — see Getting Started

  • Lab Control: The caller must be the Lab's controller (the current LabNFT owner)

  • Base ETH Balance: Sufficient for gas fees on Base

  • Token Details: Symbol and initial supply amount (the token name is derived automatically)


Error Handling

The Tokenization API keeps its own envelope, separate from the Labs API's ApiError. Every result, queries included, returns HTTP 200 with isSuccess and an error object:

Select error { code message retryable } on every operation, branch on error.code, and retry only when retryable is true. There's no requestId. The full code list, how this envelope differs from the Labs API, and the failures that bypass it are on the shared Errors page.

The errors you'll see in the OCL flow on this page:

Code

retryable

From

Fix

INVALID_INPUT

false

both

Check the input shape and the oclId format

INVALID_INPUT

false

getOclTermsMessage

No agreement at agreementKey, or contentHash doesn't match it. Pass the exact agreementKey and agreementContentHash returned by generateOclMembershipAgreement

INVALID_METADATA

false

generateOclMembershipAgreement

agreementData couldn't be parsed as JSON. Check the string you stringified

INTERNAL_ERROR

true

both

Retry with backoff

A missing or invalid consumer credential is rejected with HTTP 401 before any of this runs. Check the Authorization header: the mol_ credential goes in directly, with no Bearer prefix.

Separately, the smart contracts revert with their own errors — most commonly AlreadyTokenized() (each Lab can only be tokenized once) and MustControlLab() (only the Lab's controller can tokenize) from the OclTokenizer.

Troubleshooting

Signature rejected onchain:

  • Sign exactly the string returned by getOclTermsMessage — the permissioner reconstructs the terms onchain and the texts must match byte-for-byte

  • Use a plain personal_sign (EIP-191) signature, and sign with the Lab controller's wallet (or a smart account that validates via ERC-1271)

Blockchain Transaction Failures:

  • Verify sufficient ETH balance for gas on Base

  • Ensure using correct contract address for your network

  • Wait for transaction confirmation before proceeding


Complete End-to-End Examples

For complete code examples including:

  • The full Lab tokenization flow with code

  • Smart contract ABIs and interfaces

  • Error handling and retry logic

  • Safe multisig integration

Contract addresses, ABIs and interfaces are published in the Contracts reference — OclTokenizer, IPToken, AccessResolver — so no request is needed for those. For the remaining narrative material (Safe multisig integration, worked retry logic), ask on the Molecule Discord, naming the Technical Integration Guide.

Basic Example Structure


Smart Contract Details

Contract ABIs:

  • Available from the verified OclTokenizer on BaseScan, or request them from the Molecule team as part of the Technical Integration Guide


Best Practices

Workflow Management

  • Store intermediate results (agreement keys, signatures) securely

  • Implement retry logic for failed API calls

  • Wait for blockchain transaction confirmations

  • Validate each step before proceeding to next

Security

  • Never expose consumer credentials in client-side code

  • Use environment variables for credentials

  • Implement proper wallet key management

  • Verify all signatures and authorizations

Testing

  • Use the sandbox (Base Sepolia) for development

  • Test the complete workflow end-to-end

  • Verify the agreement document and terms text before signing


Getting Support

For assistance with the Tokenization API:

  • Smart contracts: addresses, ABIs and interfaces are published in the Contracts reference — no request needed

  • Consumer credential: created on the API credentials page of the Labs app — see Getting Started

  • Technical Integration Guide: ask on Discord, naming the guide

  • Discord: join our community for support


Last updated: July 2026

Need help?

Ask the team on Discord. Reporting an API error? Include the requestId from the failing response so we can trace it.

Ask on Discord

Page wrong, unclear or missing something? Let us know with Was this helpful? on this page.

Last updated

Was this helpful?