Use cases
Explore
Docs
Pricing

Organigram JS

Organigram JS is the JavaScript/TypeScript client for the Organigram Protocol, a suite of smart contracts for running organizations on Ethereum-compatible blockchains. It deploys, reads and operates those contracts from any JavaScript environment, browser or Node.js, and is the library used under the hood by Organigram.ai and by @organigram/react.

Installation


pnpm add @organigram/js viem

viem is a peer dependency: Organigram JS never holds keys itself, it uses the viem clients you give it.

How it works

An organization is modelled as an organigram: a set of organs connected by procedures, optionally holding assets. Each of them is a smart contract, and each has a class in this library that loads its on-chain state, writes to it, and serializes it to JSON.

ClassRole
OrganigramClientEntry point. Connects to the protocol on one chain, deploys contracts and loads them.
OrganigramThe whole organization: its organs, assets and procedures, as a draft or as deployed contracts. It has no contract of its own.
OrganA group: a registry of entries (members, documents), a list of permissions, and a balance of assets.
ProcedureThe rules by which the members of some organs may change other organs.
NominationProcedureA procedure where any one member of the deciders organ adopts or rejects a proposal alone.
VoteProcedureA procedure where the members of an organ vote.
ERC20VoteProcedureA procedure where votes are weighted by an ERC-20 token.
AssetAn ERC-20 token, either a plain asset or company equity.

The client

OrganigramClient.load() connects to the OrganigramClient contract deployed on the chain of your viem public client, and reads the procedure types registered there. The public client is used for every read; the wallet client, when provided, signs the transactions. Without a wallet client, the library is read-only.

The client keeps loaded organs, procedures and assets in memory: loadOrgan(), loadProcedure() and loadAsset() return the cached object unless you pass { fresh: true }.

Organs and permissions

An organ stores three things:

  • entries: each one an Ethereum address (a member) or a content reference (a document), or both;
  • permissions: which addresses may act on the organ, as a bit field from PERMISSIONS (ADD_ENTRIES, WITHDRAW_ETHER, ADD_PERMISSIONS…). getPermissionsSet() turns a value back into names;
  • assets: ether and ERC-20 tokens, which only addresses with the matching permission can withdraw.

In a governed organization, permissions are granted to procedures rather than to people, so that every change goes through a decision.

Proposals and decisions

A procedure names three roles, each held by the members of an organ (or, for an ERC-20 vote, by the token holders): the proposers who may submit proposals, the moderators who may filter them when moderation is enabled, and the deciders who adopt or reject them. A proposal is a list of operations, calls to organs that the procedure has permission to make, plus a reference to its off-chain metadata.

  1. propose() submits the proposal.
  2. With moderation, a moderator either accepts it with presentProposal() or rejects it with blockProposal().
  3. The deciders decide: nominate() or reject() for a nomination, vote() then count() once the vote is over for the vote procedures.
  4. Adoption executes the operations on the target organs. applyProposal() retries the operations that were not processed yet.

Every write also exists as a …BySig variant: the user signs an EIP-712 message and any relayer submits it, so users do not need gas.

Deploying an organigram

organigram.deploy() deploys organs, assets and procedures in one transaction, then loads them back from the chain. Under the hood it calls client.deployOrganigram(), which you can call directly when you only need the new addresses. Contracts are deployed as clones at addresses predicted from a salt, which lets a draft reference contracts that do not exist yet, for example a procedure deciding on an organ deployed in the same batch. templates provides ready-made organigrams (sas, sarl, nonProfit, openSource…), and isTemplateSupportedOnChain() tells whether a chain has the contracts a template needs.

Off-chain storage

Contracts only store references. Metadata and documents live off-chain and are referenced by CID refs of the form og://workspace/<workspace>/<key>, built with formatCidRef() and read with parseCidRef(). Proposals must carry such a reference.

The encryption helpers (generateUserEncryptionKeyPair, wrapGroupKeyForRecipient, encryptBytes…) implement the end-to-end encryption of documents used by Organigram.ai: content keys encrypt documents, group keys wrap content keys, and each member's key pair unwraps group keys. They run on the Web Crypto API of the user's device. Keep private keys there: never send them to a server, never log them, and only export them to a storage you encrypt yourself.

Usage

Connect to the protocol with a browser wallet:


import { OrganigramClient } from '@organigram/js'
import { createPublicClient, createWalletClient, custom, http } from 'viem'
import { sepolia } from 'viem/chains'
const [account] = await window.ethereum.request({ method: 'eth_requestAccounts' })
const publicClient = createPublicClient({ chain: sepolia, transport: http() })
const walletClient = createWalletClient({
account,
chain: sepolia,
transport: custom(window.ethereum)
})
const client = await OrganigramClient.load({ publicClient, walletClient })

Deploy an organization from a template:


import { Organigram, getTemplate } from '@organigram/js'
const organigram = await new Organigram({
...getTemplate('nonProfit', client.chainId),
organigramClient: client
}).deploy()

Propose to add a member to an organ, then adopt the proposal through a nomination procedure:


import { NominationProcedure, Organ, Procedure, formatCidRef } from '@organigram/js'
const procedure = (await client.loadProcedure(
procedureAddress
)) as NominationProcedure
const call = await Organ.populateTransaction(organAddress, walletClient, 'addEntries', [
{ address: newMemberAddress }
])
const proposal = await procedure.propose({
cid: formatCidRef({ scopeType: 'workspace', scopeId: workspaceId }, 'add-member'),
operations: [Procedure.createOperation(call)]
})
await procedure.nominate(proposal.key)

The procedure must hold the ADD_ENTRIES permission on the organ, and the connected account must belong to its proposers and deciders.

Contributing

We are looking for TypeScript developers and testers to keep this project secure and up to date. Please open issues on GitHub, fork the repository and send pull requests.

Client

Everything starts with an OrganigramClient, connected to the protocol on one chain through two viem clients: a public client to read, and a wallet client to sign. Without a wallet client, the library is read-only. The client deploys contracts, loads them, and keeps what it loaded in cache until you ask for a fresh read. Every write accepts TransactionOptions, to follow a transaction as soon as it is sent.

OrganigramClient

Main SDK entry point used to deploy and hydrate Organigram Protocol objects.

It keeps a public client, an optional wallet client, the registered procedure types for the current chain, and small in-memory caches for loaded organs, procedures, and assets.

Definition

constructor(input: {
publicClient: PublicClient;
address?: string;
chainId?: string;
procedureTypes?: ProcedureType[];
contract?: OrganigramContract;
walletClient?: WalletClient;
});

PropertyTypeDescription
addressstringAddress of the OrganigramClient contract.
assetsAsset[]Assets loaded so far, kept in cache.
chainIdstringChain the client is connected to.
contractOrganigramContractviem contract instance of the OrganigramClient contract.
organsOrgan[]Organs loaded so far, kept in cache.
proceduresProcedure[]Procedures loaded so far, kept in cache.
procedureTypesProcedureType[]Procedure types registered on this chain.
publicClientPublicClientClient used for every read.
walletClientWalletClientClient that signs transactions. Without it, the client is read-only.

OrganigramClient.deployAsset

Deploy a single ERC-20 asset clone.

Signature

deployAsset(input: {
name: string;
symbol: string;
initialSupply?: number;
salt?: string;
options?: TransactionOptions;
}): Promise<string>;

Parameters

NameTypeDescription
input{ name: string; symbol: string; initialSupply?: number; salt?: string; options?: TransactionOptions; }Token name and symbol, supply in whole tokens before conversion to wei, optional deterministic clone salt and transaction controls.

Returns

TypeDescription
Promise<string>The address of the deployed asset contract.

OrganigramClient.deployAssets

Deploy several assets in one batch transaction.

Signature

deployAssets(assets: AssetInput[], options?: TransactionOptions): Promise<string[]>;

Parameters

NameTypeDescription
assetsAssetInput[]Assets to deploy.
optionsTransactionOptionsOptional transaction controls.

Returns

TypeDescription
Promise<string[]>The deployed asset addresses in deployment order.

OrganigramClient.deployClient

Deploy a fresh Organigram client contract together with its linked library.

Signature

static deployClient(input: {
publicClient: PublicClient;
walletClient: WalletClient;
}): Promise<OrganigramClient>;

Parameters

NameTypeDescription
input{ publicClient: PublicClient; walletClient: WalletClient; }Clients used to broadcast deployments and wait for receipts.

Returns

TypeDescription
Promise<OrganigramClient>A ready-to-use SDK instance pointing at the newly deployed client.

OrganigramClient.deployOrgan

Deploy a single organ clone and hydrate the resulting SDK object.

When no permissions are provided, the connected wallet is granted the full admin bitmask by default so the organ remains operable after deployment.

Signature

deployOrgan(input?: DeployOrganInput): Promise<Organ>;

Parameters

NameTypeDescription
inputDeployOrganInputOptional organ metadata, permissions, entries, and transaction options.

OrganigramClient.deployOrganigram

Deploy a full organigram, including its organs, assets, and procedures.

Signature

deployOrganigram(input: DeployOrganigramInput): Promise<DeployOrganigramResult>;

Parameters

NameTypeDescription
inputDeployOrganigramInputBatch deployment input for the whole organigram.

Returns

TypeDescription
Promise<DeployOrganigramResult>The deployed organ, asset, and procedure addresses, and the input updated with them. Use Organigram.deploy() to get a loaded Organigram.

OrganigramClient.deployOrgans

Deploy several organs in one batch transaction.

Signature

deployOrgans(deployOrgansInput: DeployOrganInput[]): Promise<Organ[]>;

Parameters

NameTypeDescription
deployOrgansInputDeployOrganInput[]Organ definitions to deploy.

OrganigramClient.deployProcedure

Deploy a single procedure clone from one registered procedure type.

Signature

deployProcedure(input: DeployProcedureInput): Promise<Procedure>;

Parameters

NameTypeDescription
inputDeployProcedureInputProcedure type, role organs, optional metadata, and initialization args.

OrganigramClient.deployProcedures

Deploy several procedures in one batch transaction.

Signature

deployProcedures(deployProceduresInput: DeployProcedureInput[]): Promise<Procedure[]>;

Parameters

NameTypeDescription
deployProceduresInputDeployProcedureInput[]Procedure definitions to deploy.

OrganigramClient.estimateDeployOrganigramGas

Estimate the gas a full organigram deployment would use, without a wallet.

Signature

estimateDeployOrganigramGas(input: DeployOrganigramInput, account: string): Promise<bigint>;

Parameters

NameTypeDescription
inputDeployOrganigramInputBatch deployment input for the whole organigram.
accountstringAddress the deployment would be sent from.

Returns

TypeDescription
Promise<bigint>The estimated gas, or 0n when nothing remains to deploy.

OrganigramClient.getProcedureType

Infer the registered procedure type of a deployed procedure clone.

Signature

getProcedureType(procedureAddress: string): Promise<ProcedureType | null>;

Parameters

NameTypeDescription
procedureAddressstringAddress of the deployed procedure instance.

OrganigramClient.load

Connect the SDK to an already deployed Organigram client contract.

Signature

static load(input: {
address?: string;
publicClient: PublicClient;
walletClient?: WalletClient;
}): Promise<OrganigramClient>;

Parameters

NameTypeDescription
input{ address?: string; publicClient: PublicClient; walletClient?: WalletClient; }Address override plus the viem clients used for reads and writes.

OrganigramClient.loadAsset

Load one deployed asset and keep it in the client cache.

Signature

loadAsset(address: string, input?: {
fresh?: boolean;
initial?: Asset;
}): Promise<Asset>;

Parameters

NameTypeDescription
addressstringAsset contract address.
input{ fresh?: boolean; initial?: Asset; }fresh reads the chain even when the asset is cached; initial holds fallback metadata merged into the loaded asset.

OrganigramClient.loadContract

Attempt to load one deployed contract as an organ or procedure.

Signature

loadContract(address: string, input?: {
fresh?: boolean;
}): Promise<Organ | Procedure | null>;

Parameters

NameTypeDescription
addressstringContract address to inspect.
input{ fresh?: boolean; }fresh reads the chain even when the contract is cached.

OrganigramClient.loadContracts

Load a heterogeneous list of deployed contract addresses into an organigram.

Signature

loadContracts(contractAddresses: string[]): Promise<Organigram>;

Parameters

NameTypeDescription
contractAddressesstring[]Addresses to resolve as organs, procedures, or assets.

OrganigramClient.loadOrgan

Load one deployed organ and keep it in the client cache.

Signature

loadOrgan(address: string, input?: {
fresh?: boolean;
initial?: OrganInput;
}): Promise<Organ>;

Parameters

NameTypeDescription
addressstringOrgan contract address.
input{ fresh?: boolean; initial?: OrganInput; }fresh reads the chain even when the organ is cached; initial holds fallback metadata merged into the loaded organ.

OrganigramClient.loadOrganigram

Hydrate every deployed object referenced by an organigram definition.

Undeployed placeholders are preserved as-is, while deployed organs, procedures, and assets are refreshed from chain state.

Signature

loadOrganigram(organigram: Organigram, input?: {
fresh?: boolean;
}): Promise<Organigram>;

Parameters

NameTypeDescription
organigramOrganigramOrganigram definition to hydrate.
input{ fresh?: boolean; }fresh: false reuses the organs, procedures and assets already in the client cache instead of reading them again.

OrganigramClient.loadProcedure

Load one deployed procedure and keep it in the client cache.

Signature

loadProcedure(address: string, input?: {
fresh?: boolean;
initial?: ProcedureInput;
}): Promise<Procedure>;

Parameters

NameTypeDescription
addressstringProcedure contract address.
input{ fresh?: boolean; initial?: ProcedureInput; }fresh reads the chain even when the procedure is cached; initial holds fallback metadata merged into the loaded procedure.

OrganigramClient.loadProcedureType

Load metadata for one deployed procedure implementation.

Signature

static loadProcedureType(input: {
addr: string;
cid?: string;
}, publicClient: PublicClient): Promise<ProcedureType>;

Parameters

NameTypeDescription
input{ addr: string; cid?: string; }Address and optional CID used to identify the procedure type.
publicClientPublicClientRead-only client used for interface checks.

OrganigramClient.loadProcedureTypes

Read the procedure registry and resolve every supported procedure type.

Signature

static loadProcedureTypes(input: {
publicClient: PublicClient;
address?: string;
}): Promise<ProcedureType[]>;

Parameters

NameTypeDescription
input{ publicClient: PublicClient; address?: string; }Optional client contract address and the public client used to query it.

DeployOrganigramInput

Batch deployment input for a full organigram.

PropertyTypeDescription
assetsAssetInput[]Assets to deploy.
organsDeployOrganInput[]Organs to deploy.
proceduresDeployProcedureInput[]Procedures to deploy.

TransactionOptions

Options shared by every write.

PropertyTypeDescription
noncenumberTransaction nonce, to send several transactions at once.

TransactionOptions.onTransaction

Called with the transaction as soon as it is sent, before it is mined.

Signature

onTransaction?: (tx: OrganigramTransaction, description: string) => void;

DeployOrganInput

An organ to deploy: the same shape as everywhere else, plus transaction options.

Definition

export type DeployOrganInput = OrganInput & {
options?: TransactionOptions;
};

DeployProcedureInput

A procedure to deploy, plus transaction options and raw initialization arguments. Its typeName must be a known procedure type.

Definition

export type DeployProcedureInput = ProcedureInput & {
typeName: ProcedureTypeName;
options?: TransactionOptions;
args?: unknown[];
};

DeployOrganigramResult

The input is copied with its new addresses: class instances come back as plain objects.

Definition

export type DeployOrganigramResult = readonly [
organs: string[],
assets: string[],
procedures: string[]
] & {
organigram: DeployOrganigramInput;
};

ContractClients

The viem clients the SDK reads and writes with.

Definition

export type ContractClients = {
publicClient: PublicClient;
walletClient?: WalletClient | null;
};

OrganigramContract

A viem contract instance bound to the SDK clients.

Definition

export type OrganigramContract = GetContractReturnType<Abi, PublicClient | {
public: PublicClient;
wallet: WalletClient;
}>;

OrganigramTransaction

A sent transaction, with a wait() that resolves once it is mined.

Definition

export type OrganigramTransaction = {
hash: Hex;
wait: () => Promise<OrganigramTransactionReceipt>;
};

OrganigramTransactionReceipt

The receipt of a mined transaction.

Definition

export type OrganigramTransactionReceipt = TransactionReceipt & {
gasPrice?: bigint | null;
};

bufferEstimatedGas

Add a 20% margin plus 25,000 gas to a gas estimate.

Signature

bufferEstimatedGas: (estimatedGas: bigint) => bigint

createContractWriteTransaction

Send a contract call with a buffered gas estimate, and return it as an OrganigramTransaction.

Signature

createContractWriteTransaction: <TAbi extends Abi | readonly unknown[]>(input: {
address: string;
abi: TAbi;
functionName: string;
args?: unknown[];
clients: ContractClients;
nonce?: number;
value?: bigint;
}) => Promise<OrganigramTransaction>

getWalletAddress

Return the address of the account a wallet client signs with.

Signature

getWalletAddress: (walletClient: WalletClient) => Promise<Address>

Organigrams and templates

An Organigram gathers the organs, procedures and assets of one organization. Start from a template with getTemplate(), or from your own data, attach a client, and deploy everything in one transaction with organigram.deploy(). Contracts are clones at addresses predicted from a salt, so that a draft can reference contracts that do not exist yet.

Organigram

A whole organization: its organs, procedures and assets, as a draft or as deployed contracts.

The organigram itself has no contract. Create one from a template or from data, attach an OrganigramClient, then call deploy().


const organigram = await new Organigram({
...getTemplate('nonProfit', client.chainId),
organigramClient: client
}).deploy()

Definition

constructor(input?: OrganigramInput | keyof typeof templates | string[]);

PropertyTypeDescription
assetsAsset[]Assets of the organization.
chainIdstringChain the organigram is deployed on.
descriptionstringFree description.
edgeTypeOrganigramEdgeTypeLine style of the diagram links.
idstringIdentifier of the organigram.
namestringDisplay name.
nodePositionsOrganigramNodePositionsPositions of the diagram nodes.
organigramClientOrganigramClient | nullClient used to deploy and load the organigram.
organsOrgan[]Organs of the organization.
proceduresProcedure[]Procedures connecting the organs.
publicClientPublicClient | nullClient used for reads, when no organigramClient is attached.
slugstringURL-friendly name.
walletClientWalletClient | nullClient that signs transactions, when no organigramClient is attached.
workspaceIdstring | nullWorkspace the organigram belongs to in the Organigram app.

Organigram.deploy

Deploy every contract of the organigram in one transaction, then read them back from chain.

Requires an attached organigramClient with a wallet client.

Signature

deploy(): Promise<Organigram>;

Organigram.editDetails

Change the name, description or diagram layout.

Signature

editDetails(input: {
name?: string;
description?: string;
edgeType?: OrganigramEdgeType;
nodePositions?: OrganigramNodePositions;
contractAddresses?: string[];
}): void;

Organigram.load

Read every deployed organ, procedure and asset of the organigram from chain.

Signature

load: (input?: {
walletClient?: WalletClient | null;
publicClient?: PublicClient | null;
}) => Promise<Organigram>;

Organigram.setAssets

Replace the assets.

Signature

setAssets(assets: Asset[]): void;

Organigram.setOrgans

Replace the organs.

Signature

setOrgans(organs: Organ[]): void;

Organigram.setProcedures

Replace the procedures.

Signature

setProcedures(procedures: Procedure[]): void;

Organigram.toJson

Convert the organigram into plain JSON.

Signature

toJson: () => OrganigramJson;

OrganigramEdgeType

Line style of the links of an organigram.

Definition

export type OrganigramEdgeType = (typeof organigramEdgeTypes)[number];

OrganigramInput

The data of an organigram, such as a template from getTemplate().

Definition

export type OrganigramInput = {
id?: string | null;
slug?: string | null;
name?: string | null;
description?: string | null;
edgeType?: string | null;
nodePositions?: unknown;
chainId?: string | null;
organs: OrganInput[];
procedures: ProcedureInput[];
assets: AssetInput[];
organigramClient?: OrganigramClient | null;
walletClient?: WalletClient | null;
publicClient?: PublicClient | null;
contractAddresses?: string[] | null;
workspaceId?: string | null;
};

OrganigramJson

An organigram as plain JSON, to store or send it.

Definition

export type OrganigramJson = {
id: string;
slug: string;
name: string;
description: string;
edgeType: OrganigramEdgeType;
nodePositions: OrganigramNodePositions;
chainId: string;
organs: OrganJson[];
procedures: ProcedureJson[];
assets: AssetJson[];
workspaceId?: string | null;
};

OrganigramNodePosition

Position of one node in the organigram diagram.

Definition

export type OrganigramNodePosition = {
x: number;
y: number;
};

OrganigramNodePositions

Positions of the nodes in the organigram diagram, by contract address.

Definition

export type OrganigramNodePositions = Record<string, OrganigramNodePosition>;

ProcedureRoleTypeName

The three roles of a procedure: who proposes, who moderates, who decides.

Definition

export type ProcedureRoleTypeName = 'proposers' | 'moderators' | 'deciders';

defaultChainId

Chain used by templates when none is given.

Definition

const defaultChainId: string

defaultOrganigramEdgeType

Line style used when none is set.

Definition

const defaultOrganigramEdgeType: OrganigramEdgeType

organigramEdgeTypes

Line styles available to draw the links of an organigram.

Definition

const organigramEdgeTypes: readonly ["default", "straight", "step", "smoothstep"]

TemplateName

Name of a template.

Definition

export type TemplateName = keyof typeof templates;

getTemplate

Return a copy of a template, with new salts and addresses for the given chain.

Signature

getTemplate: (templateName: TemplateName, chainId: string) => OrganigramInput

isTemplateSupportedOnChain

Tell whether a chain has every protocol contract a template needs.

Signature

isTemplateSupportedOnChain: (templateName: TemplateName, chainId: string) => boolean

renewSaltsAndAddresses

Give every contract of an organigram a new salt and address, and update the references between them.

Signature

renewSaltsAndAddresses: (organigram: OrganigramInput, chainId: string) => OrganigramInput

templates

Ready-made organigrams, from company forms (sas, sarl…) to registers.

Organs

An organ is a group: a registry of entries, each a member, a document or both, a list of permissions, and a balance of assets. Each change requires a permission from PERMISSIONS. In a governed organization, those permissions belong to procedures rather than to people, so that every change goes through a decision.

Organ

A group of the organization: a registry of members and documents, a list of permissions, and a balance of assets.

Every change to an organ must come from an address holding the matching permission. In a governed organization, that address is a procedure, so that each change goes through a decision.

Definition

constructor(input: OrganInput);

PropertyTypeDescription
addressstringContract address, or a predicted address while it is a draft.
balancestringEther balance, in wei.
chainIdstringChain the organ lives on.
cidstringReference to the off-chain metadata of the organ.
contractOrganigramContractviem contract instance, once loaded.
descriptionstringFree description.
entriesOrganEntry[]Members and documents registered in the organ.
forwarderstringTrusted forwarder relaying gasless transactions.
INTERFACEstringERC-165 interface identifier of organ contracts.
isDeployedbooleanWhether the contract exists on chain.
namestringDisplay name.
organigramIdstringOrganigram the organ belongs to.
permissionsOrganPermission[]Addresses allowed to act on the organ, with their permission flags.
publicClientPublicClientClient used for reads.
saltstring | undefinedSalt that determines the clone address.
walletClientWalletClientClient that signs transactions.

Organ.addEntries

Add members or documents to the registry.

Signature

addEntries: (entries: OrganEntryInput[], options?: TransactionOptions) => Promise<OrganigramTransactionReceipt>;

Organ.addPermission

Grant permissions to an address.

Signature

addPermission: (permission: OrganPermission, options?: TransactionOptions) => Promise<OrganigramTransactionReceipt>;

Organ.checkAddressPermissions

Read the permission flags an address holds on an organ.

Signature

static checkAddressPermissions(organAddress: string, addressToCheck: string, clients: ContractClients): Promise<number>;

Organ.getBalance

Read the ether balance of an organ, in wei.

Signature

static getBalance(address: string, clients: ContractClients): Promise<bigint>;

Organ.isOrgan

Tell whether a contract is an organ.

Signature

static isOrgan(address: string, clients: ContractClients): Promise<boolean>;

Organ.load

Read an organ from chain: its entries, permissions and metadata.

Signature

static load(address: string, clients: ContractClients, initialOrgan?: OrganInput): Promise<Organ>;

Organ.loadData

Read the metadata reference and registry sizes of an organ.

Signature

static loadData(address: string, clients: ContractClients): Promise<OrganContractData>;

Organ.loadEntries

Read every entry of an organ.

Signature

static loadEntries(address: string, clients: ContractClients, data?: OrganContractData): Promise<OrganEntry[]>;

Organ.loadEntry

Read one entry of an organ, by index.

Signature

static loadEntry(address: string, index: string, clients: ContractClients): Promise<OrganEntry>;

Organ.loadEntryForAccount

Find the entry of an address in an organ, if it is a member.

Signature

static loadEntryForAccount(address: string, account: string, clients: ContractClients): Promise<OrganEntry | undefined>;

Organ.loadPermission

Read one permission of an organ, by index.

Signature

static loadPermission(address: string, index: string, clients: ContractClients): Promise<OrganPermission>;

Organ.loadPermissions

Read every permission of an organ.

Signature

static loadPermissions(address: string, clients: ContractClients, data?: OrganContractData): Promise<OrganPermission[]>;

Organ.populateTransaction

Encode a call to an organ function, to use it as a proposal operation with Procedure.createOperation().


const call = await Organ.populateTransaction(organAddress, walletClient, 'addEntries', [
{ address: memberAddress }
])
const operation = Procedure.createOperation(call)

Signature

static populateTransaction(address: string, walletClient: WalletClient, functionName: OrganFunctionName | string, ...args: unknown[]): Promise<{
to: string;
data: string;
functionName: string;
}>;

Organ.reload

Read the whole organ again from chain.

Signature

reload(): Promise<Organ>;

Organ.reloadData

Read the metadata reference again from chain.

Signature

reloadData(): Promise<Organ>;

Organ.reloadEntries

Read the entries again from chain.

Signature

reloadEntries(): Promise<Organ>;

Organ.reloadPermissions

Read the permissions again from chain.

Signature

reloadPermissions(): Promise<Organ>;

Organ.removeEntries

Remove entries from the registry, by index.

Signature

removeEntries: (indexes: string[], options?: TransactionOptions) => Promise<OrganigramTransactionReceipt>;

Organ.removePermission

Revoke every permission of an address.

Signature

removePermission: (permission: string, options?: TransactionOptions) => Promise<OrganigramTransactionReceipt>;

Organ.replaceEntry

Replace one entry of the registry.

Signature

replaceEntry: (index: number, entry: OrganEntryInput, options?: TransactionOptions) => Promise<OrganigramTransactionReceipt>;

Organ.replacePermission

Move permissions from one address to another.

Signature

replacePermission: (oldPermissionAddress: string, newOrganPermission: OrganPermission, options?: TransactionOptions) => Promise<OrganigramTransactionReceipt>;

Organ.toJson

Convert the organ into plain JSON.

Signature

toJson: () => OrganJson;

Organ.updateCid

Replace the reference to the off-chain metadata of the organ.

Signature

updateCid: (cid: string, options?: TransactionOptions) => Promise<OrganigramTransactionReceipt>;

Organ.withdrawERC20

Send ERC-20 tokens held by the organ.

Signature

withdrawERC20: (token: string, to: string, amount: string | number | bigint, options?: TransactionOptions) => Promise<OrganigramTransactionReceipt>;

Organ.withdrawERC721

Send an ERC-721 token held by the organ.

Signature

withdrawERC721: (token: string, to: string, tokenId: string | number | bigint, options?: TransactionOptions) => Promise<OrganigramTransactionReceipt>;

Organ.withdrawEther

Send ether held by the organ.

Signature

withdrawEther: (to: string, value: string | number | bigint, options?: TransactionOptions) => Promise<OrganigramTransactionReceipt>;

OrganEntry

One entry of an organ registry: a member, a document, or both.

PropertyTypeDescription
addressstringEthereum address of the member, or the zero address.
cidstringReference to a document, or an empty string.
indexstringPosition in the registry, starting at 1.
namestring | nullDisplay name.

OrganEntryInput

An entry to add to an organ: an address, a document reference, or both.

PropertyTypeDescription
addressstringEthereum address of the member.
cidstringReference to a document.

OrganInput

The data of an organ, deployed or still a draft.

PropertyTypeDescription
addressstring | nullContract address, or a predicted address while it is a draft.
balancestring | nullEther balance, in wei.
chainIdstring | nullChain the organ lives on.
cidstring | nullReference to the off-chain metadata of the organ.
descriptionstring | nullFree description.
entriesArray<{ index: string; address: string; cid: string; name?: string | null; }> | nullMembers and documents registered in the organ.
forwarderstring | nullTrusted forwarder relaying gasless transactions.
isDeployedboolean | nullWhether the contract exists on chain.
namestring | nullDisplay name.
organigramIdstring | nullOrganigram the organ belongs to.
permissionsOrganPermission[] | nullAddresses allowed to act on the organ, with their permission flags.
publicClientPublicClient | nullClient used for reads.
saltstring | nullSalt that determines the clone address.
walletClientWalletClient | nullClient that signs transactions.

OrganJson

An organ as plain JSON, to store or send it.

PropertyTypeDescription
addressstringContract address, or a predicted address while it is a draft.
balancestringEther balance, in wei.
chainIdstringChain the organ lives on.
cidstringReference to the off-chain metadata of the organ.
descriptionstringFree description.
entriesOrganEntry[]Members and documents registered in the organ.
isDeployedbooleanWhether the contract exists on chain.
namestringDisplay name.
organigramIdstringOrganigram the organ belongs to.
permissionsOrganPermission[]Addresses allowed to act on the organ, with their permission flags.
saltstring | nullSalt that determines the clone address.

OrganPermission

The permissions one address holds on an organ.

PropertyTypeDescription
permissionAddressstringAddress granted the permissions, usually a procedure.
permissionValuenumberBit field of PERMISSIONS flags.

OrganFunctionName

The organ functions a proposal operation can call.

NameValueDescription
addEntries"addEntries"Add entries.
addPermission"addPermission"Grant permissions to an address.
removeEntries"removeEntries"Remove entries.
removePermission"removePermission"Revoke the permissions of an address.
replaceEntry"replaceEntry"Replace one entry.
replacePermission"replacePermission"Move permissions to another address.
withdrawERC20"withdrawERC20"Send ERC-20 tokens.
withdrawERC721"withdrawERC721"Send an ERC-721 token.
withdrawEther"withdrawEther"Send ether.

getPermissionsSet

List the names of the permissions in a permission value.

Signature

getPermissionsSet: (permissions: number) => string[]

PERMISSIONS

Bit flags of the permissions an address can hold on an organ. Combine them with |.


PERMISSIONS.ADD_ENTRIES | PERMISSIONS.REMOVE_ENTRIES

Procedures and proposals

A procedure lets the members of some organs change other organs. Proposers submit a proposal, a list of operations built with Procedure.createOperation(). With moderation, a moderator presents or blocks it. Deciders then adopt or reject it, alone in a NominationProcedure, by vote in a VoteProcedure, or by token-weighted vote in an ERC20VoteProcedure, and adoption runs the operations. Every action also exists as a signed variant: the user signs with a sign… method, and any account submits the signature with the matching …BySig method, so that users need no gas.

Procedure

The rules by which the members of some organs may change other organs.

A proposal is a list of operations. Proposers submit it with propose(). With moderation, a moderator presents it with presentProposal() or blocks it with blockProposal(). Deciders then adopt or reject it, depending on the procedure type, and adoption runs its operations. Every action also has a signed variant (sign… then …BySig), so that a relayer submits it and users need no gas.

Definition

constructor(input: ProcedureInput);

PropertyTypeDescription
addressstringContract address, or a predicted address while it is a draft.
chainIdstringChain the procedure lives on.
cidstringReference to the off-chain metadata of the procedure.
contractOrganigramContractviem contract instance, once loaded.
datastringParameters specific to the procedure type, as a JSON string, such as the vote duration.
decidersstringOrgan whose members adopt or reject proposals, or a single address.
descriptionstringFree description.
forwarderstringTrusted forwarder relaying gasless transactions.
INTERFACEstringERC-165 interface identifier of procedure contracts.
isDeployedbooleanWhether the contract exists on chain.
metadatastringOff-chain metadata, as a JSON string.
moderatorsstringOrgan whose members may present or block proposals, when moderation is enabled.
namestringDisplay name.
OPERATIONS_FUNCTIONSProcedureProposalOperationFunction[]Functions a proposal operation can call, with what a form needs to build them.
organigramIdstringOrganigram the procedure belongs to.
proposalsProcedureProposal[]Proposals submitted so far.
proposersstringOrgan whose members may submit proposals, or a single address.
publicClientPublicClientClient used for reads.
saltstringSalt that determines the clone address.
typeProcedureTypeRegistered procedure type this procedure is a clone of.
typeNameProcedureTypeNameProcedure type: nomination, vote or erc20Vote.
walletClientWalletClientClient that signs transactions.
withModerationbooleanWhether proposals must be presented by a moderator before the decision.

Procedure.applyProposal

Settle a proposal: for a vote, count the ballots once it is over, then run or close it.

Signature

applyProposal(proposalKey: string, options?: TransactionOptions): Promise<OrganigramTransactionReceipt>;

Procedure.applyProposalBySig

Settle a proposal, with an application signed by another account.

Signature

applyProposalBySig(input: SignedProposalActionInput & {
signature: string;
}, options?: TransactionOptions): Promise<OrganigramTransactionReceipt>;

Procedure.blockProposal

Block a proposal as a moderator, before its decision.

Signature

blockProposal(proposalKey: string, reason: string, options?: TransactionOptions): Promise<OrganigramTransactionReceipt>;

Procedure.blockProposalBySig

Block a proposal signed by a moderator.

Signature

blockProposalBySig(input: SignedBlockProposalInput & {
signature: string;
}, options?: TransactionOptions): Promise<OrganigramTransactionReceipt>;

Procedure.createExternalCallOperation

Build an operation that makes an organ call a contract outside the organization.

Signature

static createExternalCallOperation(input: ExternalCallOperationInput): ProcedureProposalOperation;

Procedure.createOperation

Turn a contract call, such as the result of Organ.populateTransaction(), into a proposal operation.

Signature

static createOperation(input: {
to: string;
data: string;
value?: number | string | bigint;
index?: number | string;
}): ProcedureProposalOperation;

Procedure.getClients

The viem clients of the procedure.

Signature

protected getClients(): ContractClients;

Procedure.getNonce

Read the next signature nonce of an account.

Signature

getNonce(account: string): Promise<bigint>;

Procedure.getTypedDataDomain

EIP-712 domain of the signatures of this procedure.

Signature

getTypedDataDomain(): {
name: string;
version: string;
chainId: bigint;
verifyingContract: `0x${string}`;
};

Procedure.isProcedure

Tell whether a contract is a procedure.

Signature

static isProcedure(address: string, clients: ContractClients): Promise<boolean>;

Procedure.load

Read a procedure from chain, with its proposals.

Signature

static load(address: string, clients: ContractClients, initialProcedure?: ProcedureInput): Promise<Procedure>;

Procedure.loadData

Read the roles, metadata reference and proposal count of a procedure.

Signature

static loadData(address: string, clients: ContractClients): Promise<ProcedureContractData>;

Procedure.loadProposal

Read one proposal of a procedure.

Signature

static loadProposal(address: string, proposalKey: string, clients: ContractClients): Promise<ProcedureProposal>;

Procedure.loadProposals

Read every proposal of a procedure.

Signature

static loadProposals(address: string, clients: ContractClients, data?: ProcedureContractData): Promise<ProcedureProposal[]>;

Procedure.parseOperation

Normalize an operation read from chain.

Signature

static parseOperation(rawOperation: unknown): ProcedureProposalOperation;

Procedure.presentProposal

Present a proposal to the deciders, as a moderator.

Signature

presentProposal(proposalKey: string, options?: TransactionOptions): Promise<OrganigramTransactionReceipt>;

Procedure.presentProposalBySig

Present a proposal signed by a moderator.

Signature

presentProposalBySig(input: SignedProposalActionInput & {
signature: string;
}, options?: TransactionOptions): Promise<OrganigramTransactionReceipt>;

Procedure.propose

Submit a proposal.

Signature

propose(input: {
cid: string;
operations: ProcedureProposalOperation[];
options?: TransactionOptions;
}): Promise<ProcedureProposal>;

Parameters

NameTypeDescription
input{ cid: string; operations: ProcedureProposalOperation[]; options?: TransactionOptions; }Reference to the proposal metadata, which must be a CID reference, and its operations.

Procedure.proposeBySig

Submit a proposal signed by another account.

Signature

proposeBySig(input: SignedProposalInput & {
signature: string;
}): Promise<OrganigramTransaction>;

Procedure.reloadData

Read the roles and metadata reference again from chain.

Signature

reloadData(): Promise<Procedure>;

Procedure.reloadProposal

Read one proposal again from chain.

Signature

reloadProposal(proposalKey: string): Promise<Procedure>;

Procedure.reloadProposals

Read every proposal again from chain.

Signature

reloadProposals(): Promise<Procedure>;

Procedure.signApplyProposal

Sign the application of a proposal, for applyProposalBySig().

Signature

signApplyProposal(input: SignedProposalActionInput): Promise<string>;

Procedure.signBlockProposal

Sign the block of a proposal, for blockProposalBySig().

Signature

signBlockProposal(input: SignedBlockProposalInput): Promise<string>;

Procedure.signPresentProposal

Sign the presentation of a proposal, for presentProposalBySig().

Signature

signPresentProposal(input: SignedProposalActionInput): Promise<string>;

Procedure.signProposal

Sign a proposal, so that another account submits it with proposeBySig().

The signer pays no gas: any account can submit the signature with the matching …BySig method.

Signature

signProposal(input: SignedProposalInput): Promise<string>;

Procedure.toJson

Convert the procedure into plain JSON.

Signature

toJson: () => ProcedureJson;

ExternalCallOperationInput

A call to a contract outside the organization, made by an organ.

PropertyTypeDescription
datastringEncoded call.
indexstring | numberPosition of the operation in the proposal.
organAddressstringOrgan making the call. It must allow this call in its execution whitelist.
targetstringContract called.
valuestring | bigint | numberEther sent with the call, in wei.

OperationParam

One decoded parameter of an operation, to display or edit it.

PropertyTypeDescription
actionOperationParamActionWhat the parameter is used for.
parserunknownFunction turning the form value into the call argument.
typeOperationParamTypeKind of the parameter.
valueunknownDecoded value.

ProcedureInput

The data of a procedure, deployed or still a draft.

PropertyTypeDescription
addressstring | nullContract address, or a predicted address while it is a draft.
chainIdstring | nullChain the procedure lives on.
cidstring | nullReference to the off-chain metadata of the procedure.
datastring | nullParameters specific to the procedure type, as a JSON string, such as the vote duration.
decidersstringOrgan whose members adopt or reject proposals, or a single address.
descriptionstring | nullFree description.
forwarderstring | nullTrusted forwarder relaying gasless transactions.
isDeployedboolean | nullWhether the contract exists on chain.
metadatastring | nullOff-chain metadata, as a JSON string.
moderatorModeERC20VoteRoleMode | nullWhether moderators are organ members, token holders, or nobody.
moderatorsstring | nullOrgan whose members may present or block proposals, when moderation is enabled.
namestring | nullDisplay name.
organigramIdstring | nullOrganigram the procedure belongs to.
proposalsProcedureProposal[] | nullProposals submitted so far.
proposerModeERC20VoteRoleMode | nullWhether proposers are organ members, token holders, or nobody.
proposersstring | nullOrgan whose members may submit proposals, or a single address.
publicClientPublicClient | nullClient used for reads.
requireMemberMajorityboolean | nullWhether a majority of the deciders organ must also approve, besides the token-weighted vote.
saltstring | nullSalt that determines the clone address.
typeProcedureTypeRegistered procedure type this procedure is a clone of.
typeNamestringProcedure type: nomination, vote or erc20Vote.
voterModeERC20VoteRoleMode | nullWhether voters are organ members or token holders.
walletClientWalletClient | nullClient that signs transactions.
withModerationboolean | nullWhether proposals must be presented by a moderator before the decision.

ProcedureProposal

A proposal submitted to a procedure, and where it stands.

PropertyTypeDescription
adoptedbooleanWhether the deciders adopted it.
appliedbooleanWhether it is settled: operations run if adopted, closed if rejected.
blockedbooleanWhether a moderator blocked it.
blockReasonstringWhy a moderator blocked it.
cidstringReference to its off-chain metadata.
creatorstringAddress that submitted it.
keystringIdentifier of the proposal in its procedure.
metadataProposalMetadataOff-chain metadata, once loaded.
operationsProcedureProposalOperation[]Calls made once adopted.
presentedbooleanWhether it reached the deciders, after moderation if enabled.
transactionHashstringHash of the transaction that submitted it.

ProcedureProposalOperation

One call a proposal makes once adopted.

Build it with Procedure.createOperation() rather than by hand.

PropertyTypeDescription
datastringEncoded call.
descriptionstringExplanation shown to the user.
functionProcedureProposalOperationFunctionThe function called, when it is a known one.
functionSelectorstringFour-byte selector of the function called.
indexstringPosition in the proposal.
paramsOperationParam[]Decoded parameters, to display them.
processedbooleanWhether the call has run.
targetstringContract called. The zero address calls the procedure itself.
valuestringEther sent with the call, in wei.

ProcedureProposalOperationFunction

A function a proposal operation can call, with what a form needs to build the call.

PropertyTypeDescription
abiunknownABI fragment, for functions outside the organ contract.
funcSigstringFour-byte function selector.
keyOperationKeyFunction name.
labelstringDisplay label.
paramsOperationParamType[]Kinds of its parameters, in order.
signaturestringSolidity signature.
tagsOperationTag[]Keywords describing the function.
target'organ' | 'self'Whether the call targets an organ or the procedure itself.

ProcedureType

A procedure implementation registered on a chain, which procedures are cloned from.

PropertyTypeDescription
addressstringAddress of the implementation contract.
fields{ [key: string]: ProcedureTypeField; }Parameters specific to the type, by name.
keystringProcedure type name.
metadata{ cid?: string; label?: string; description?: string; }Label, description and metadata reference of the type.

ProcedureTypeField

A parameter of a procedure type, as shown in a form, such as the vote duration.

PropertyTypeDescription
defaultValuestringValue used when none is given.
descriptionstringExplanation shown to the user.
labelstringDisplay label.
namestringKey of the parameter in the procedure data.
type'string' | 'number' | 'boolean' | 'roleMode' | 'moderatorRoleMode'Input kind.

ProposalMetadata

What a proposal says, stored off-chain: title, description and attachments.

PropertyTypeDescription
cidstringReference to an attached file.
descriptionstringDescription.
discussionstringLink to a discussion.
filestringAttached file name.
subtitlestringSubtitle.
titlestringTitle.

SignedBlockProposalInput

A proposal block to sign, so that another account submits it.

Extends SignedProposalActionInput.

PropertyTypeDescription
reasonstringWhy the proposal is blocked.

SignedProposalActionInput

An action on a proposal to sign, so that another account submits it.

PropertyTypeDescription
deadlinebigint | numberUnix time, in seconds, after which the signature is refused.
noncebigintCurrent signature nonce of the signer, from getNonce().
proposalKeystringProposal the action applies to.

SignedProposalInput

A proposal to sign, so that another account submits it.

PropertyTypeDescription
cidstringReference to the proposal metadata.
deadlinebigint | numberUnix time, in seconds, after which the signature is refused.
noncebigintCurrent signature nonce of the signer, from getNonce().
operationsProcedureProposalOperation[]Operations of the proposal.

AccountInOrgans

The roles an account holds in a procedure.

Definition

export type AccountInOrgans = {
moderators?: boolean;
proposers?: boolean;
deciders?: boolean;
};

Election

The state of the vote on one proposal.

Definition

export type Election = {
proposalKey: string;
start: string;
votesCount: string;
hasVoted: boolean;
approvals?: string;
objections?: string;
eligibleVotes?: string;
approved?: boolean;
};

OperationKey

The function an operation calls, as listed in Procedure.OPERATIONS_FUNCTIONS.

Definition

export type OperationKey = 'addEntries' | 'removeEntries' | 'replaceEntry' | 'addPermission' | 'removePermission' | 'replacePermission' | 'updateMetadata' | 'withdrawEther' | 'withdrawERC20' | 'withdrawERC721' | 'externalCall' | string;

OperationParamAction

What an operation parameter is used for in a form.

Definition

export type OperationParamAction = 'select' | 'create' | 'update' | 'delete' | 'withdraw' | 'deposit' | 'transfer' | 'block';

OperationParamType

Kind of a parameter of an operation, used to build its form.

Definition

export type OperationParamType = 'cid' | 'entry' | 'entries' | 'address' | 'bytes' | 'addresses' | 'index' | 'indexes' | 'organ' | 'oldPermissionAddress' | 'newPermissionAddress' | 'permissionAddress' | 'permissionValue' | 'proposal' | 'proposals' | 'amount' | 'tokenId';

OperationTag

Keyword describing what an operation does, used to filter and label it.

Definition

export type OperationTag = 'cid' | 'entries' | 'permissions' | 'coins' | 'collectibles' | 'erc721' | 'erc20' | 'erc1155' | 'ether' | 'add' | 'replace' | 'remove' | 'deposit' | 'withdraw' | 'transfer';

ProcedureJson

A procedure as plain JSON, to store or send it.

Definition

export type ProcedureJson = {
isDeployed: boolean;
address: string;
deciders: string;
typeName: ProcedureTypeName;
name: string;
description: string;
cid: string;
salt?: string | null;
chainId: string;
data: string;
metadata?: string;
proposers: string;
moderators: string;
withModeration: boolean;
proposerMode?: ERC20VoteRoleMode;
moderatorMode?: ERC20VoteRoleMode;
voterMode?: ERC20VoteRoleMode;
requireMemberMajority?: boolean;
forwarder: string;
proposals?: ProcedureProposal[];
args?: unknown[];
type: ProcedureType;
organigramId?: string | null;
};

NominationProcedure

A procedure in which any one member of the deciders adopts or rejects a proposal alone.

Definition

constructor(procedureInput: ProcedureInput);

PropertyTypeDescription
contractOrganigramContractviem contract instance, once loaded.
INTERFACEstringERC-165 interface identifier of nomination procedures.
typeNameProcedureTypeNameAlways nomination.

NominationProcedure.load

Read a nomination procedure from chain, with its proposals.

Signature

static load(address: string, clients: ContractClients, initialProcedure?: ProcedureInput): Promise<NominationProcedure>;

NominationProcedure.nominate

Adopt a proposal as a decider, which runs its operations.

Signature

nominate(proposalKey: string, options?: TransactionOptions): Promise<void>;

NominationProcedure.nominateBySig

Adopt a proposal with an adoption signed by a decider.

Signature

nominateBySig(input: {
proposalKey: string;
nonce: bigint;
deadline: bigint | number;
signature: string;
}): Promise<void>;

NominationProcedure.reject

Reject a proposal as a decider.

Signature

reject(proposalKey: string, options?: TransactionOptions): Promise<void>;

NominationProcedure.signNomination

Sign the adoption of a proposal, for nominateBySig().

The signer pays no gas: any account can submit the signature with the matching …BySig method.

Signature

signNomination(input: {
proposalKey: string;
nonce: bigint;
deadline: bigint | number;
}): Promise<string>;

VoteProcedure

A procedure in which the members of the deciders organ vote on each proposal.

The vote opens when a proposal is presented. Once it is over, anyone calls applyProposal() to count the ballots and settle the proposal.

Definition

constructor(input: VoteProcedureInput);

PropertyTypeDescription
contractOrganigramContractviem contract instance, once loaded.
electionsElection[]State of the vote on each proposal.
INTERFACEstringERC-165 interface identifier of vote procedures.
majoritySizestringShare of the ballots that must approve, in thousandths of a percent.
quorumSizestringShare of the voters who must vote, in thousandths of a percent.
typeNameProcedureTypeNameAlways vote.
voteDurationstringDuration of the vote, in seconds.

VoteProcedure.count

Tell whether a proposal passed, once its vote is over.

Signature

count(proposalKey: string): Promise<boolean>;

VoteProcedure.load

Read a vote procedure from chain, with its proposals and elections.

Signature

static load(address: string, clients: ContractClients, initialProcedure?: ProcedureInput): Promise<VoteProcedure>;

VoteProcedure.loadElection

Read the state of the vote on one proposal.

Signature

static loadElection(address: string, proposalKey: string, clients: ContractClients, voteDuration?: bigint, contract?: OrganigramContract, blockTimestamp?: bigint): Promise<Election>;

VoteProcedure.loadElections

Read the state of the vote on every proposal.

Signature

static loadElections(address: string, clients: ContractClients, proposalsLength?: number): Promise<Election[]>;

VoteProcedure.signVote

Sign a vote, for voteBySig().

The signer pays no gas: any account can submit the signature with the matching …BySig method.

Signature

signVote(input: {
proposalKey: string;
approval: boolean;
nonce: bigint;
deadline: bigint | number;
}): Promise<string>;

VoteProcedure.toJson

Convert the procedure into plain JSON.

Signature

toJson: () => ProcedureJson;

VoteProcedure.vote

Vote for or against a proposal, as a decider.

Signature

vote(proposalKey: string, choice: 'for' | 'against', options?: TransactionOptions): Promise<void>;

VoteProcedure.voteBySig

Cast a vote signed by a decider.

Signature

voteBySig(input: {
proposalKey: string;
approval: boolean;
nonce: bigint;
deadline: bigint | number;
signature: string;
}): Promise<void>;

VoteProcedureInput

The data of a vote procedure.

Definition

export type VoteProcedureInput = ProcedureInput & {
quorumSize: string;
voteDuration: string;
majoritySize: string;
elections: Election[];
};

ERC20VoteProcedure

A vote procedure in which each ballot weighs the token balance of the voter.

Ballots weigh the balances held just before the vote opened, so tokens moved during the vote do not count twice.

Definition

constructor(input: ERC20VoteProcedureInput);

PropertyTypeDescription
contractOrganigramContractviem contract instance, once loaded.
erc20stringToken whose balances weigh the votes.
INTERFACEstringERC-165 interface identifier of ERC-20 vote procedures.
moderatorModeERC20VoteRoleModeWhether moderators are organ members, token holders, or nobody.
proposerModeERC20VoteRoleModeWhether proposers are organ members, token holders, or nobody.
requireMemberMajoritybooleanWhether a majority of the deciders organ must also approve, besides the token-weighted vote.
typeNameProcedureTypeNameAlways erc20Vote.
voterModeERC20VoteRoleModeWhether voters are organ members or token holders.

ERC20VoteProcedure.erc20Balance

Read the token balance of an account, or of the connected wallet.

Signature

erc20Balance(account?: string): Promise<bigint>;

ERC20VoteProcedure.load

Read an ERC-20 vote procedure from chain, with its proposals and elections.

Signature

static load(address: string, clients: ContractClients, initialProcedure?: ProcedureInput): Promise<ERC20VoteProcedure>;

ERC20VoteProcedure.toJson

Convert the procedure into plain JSON.

Signature

toJson: () => ProcedureJson;

ERC20VoteProcedure.vote

Vote for or against a proposal, with the weight of your tokens.

Signature

vote(proposalKey: string, choice: 'for' | 'against', options?: TransactionOptions): Promise<void>;

ERC20VoteProcedureInput

The data of an ERC-20 vote procedure.

Definition

export type ERC20VoteProcedureInput = Omit<VoteProcedureInput, 'type' | 'typeName'> & {
erc20: string;
proposerMode?: ERC20VoteRoleMode;
moderatorMode?: ERC20VoteRoleMode;
voterMode?: ERC20VoteRoleMode;
requireMemberMajority?: boolean;
};

PopulateInitializeInput

Everything needed to encode the initialization of a procedure clone.

PropertyTypeDescription
argsunknown[]Parameters specific to the procedure type, as hex strings.
cidstringReference to the procedure metadata.
decidersstringDeciders organ or address.
forwarderstringTrusted forwarder relaying gasless transactions.
moderatorModeERC20VoteRoleModeWhether moderators are organ members, token holders, or nobody.
moderatorsstringModerators organ or address.
optionsTransactionOptionsTransaction options.
proposerModeERC20VoteRoleModeWhether proposers are organ members, token holders, or nobody.
proposersstringProposers organ or address.
requireMemberMajoritybooleanWhether a majority of the deciders organ must also approve, besides the token-weighted vote.
typeNameProcedureTypeNameProcedure type.
voterModeERC20VoteRoleModeWhether voters are organ members or token holders.
withModerationbooleanWhether moderation is enabled.

ERC20VoteRoleMode

Who holds a role in an ERC-20 vote: the members of an organ, the token holders, or nobody.

Definition

export type ERC20VoteRoleMode = 'organ' | 'token' | 'disabled';

PopulatedTransactionData

Encoded call data.

Definition

export type PopulatedTransactionData = {
data: string;
};

ProcedureTypeName

Name of a procedure type.

Definition

export type ProcedureTypeName = 'erc20Vote' | 'nomination' | 'vote';

getProcedureClass

Return the SDK class of a procedure type.

Signature

getProcedureClass: (typeName: string) => Promise<typeof import("./erc20Vote").ERC20VoteProcedure | typeof import("./vote").VoteProcedure | typeof import("./nomination").NominationProcedure>

getProcedureTypes

Return the procedure types registered on a chain.

Signature

getProcedureTypes: (chainId?: string) => Partial<Record<ProcedureTypeName, ProcedureType>>

Assets

Assets are ERC-20 tokens held by organs: plain assets, or company equity whose transfers a procedure approves.

Asset

An ERC-20 token held by organs: a plain asset or company equity.

Definition

constructor(input: AssetInput);

PropertyTypeDescription
addressstringContract address, or a predicted address while it is a draft.
chainIdstringChain the asset lives on.
decisionProcedurestring | nullProcedure that approves transfers of this equity token.
descriptionstringFree description.
imagestring | nullLogo URL.
initialSupplynumberSupply minted at deployment, in whole tokens.
isDeployedbooleanWhether the contract exists on chain.
kind'asset' | 'equity'asset for a plain token, equity for company shares whose transfers a procedure approves.
namestringToken name.
organigramIdstring | nullOrganigram the asset belongs to.
saltstring | nullSalt that determines the clone address.
symbolstringToken symbol.
userBalancestringBalance of the connected wallet, in the smallest unit.

Asset.load

Hydrate an asset from chain state.

Signature

static load: (address: string, clients: ContractClients, initialAsset?: AssetInput) => Promise<(Asset & {
userBalance: string;
}) | undefined>;

Asset.toJson

Convert the asset into a JSON-safe structure.

Signature

toJson(): AssetJson;

AssetInput

The data of an asset, deployed or still a draft.

PropertyTypeDescription
addressstring | nullContract address, or a predicted address while it is a draft.
chainIdstring | nullChain the asset lives on.
decisionProcedurestring | nullProcedure authorized to settle this equity token's transfers.
descriptionstring | nullFree description.
imagestring | nullLogo URL.
initialSupplynumber | nullSupply minted at deployment, in whole tokens.
isDeployedbooleanWhether the contract exists on chain.
kind'asset' | 'equity' | nullasset for a plain token, equity for company shares whose transfers a procedure approves.
namestring | nullToken name.
organigramIdstring | nullOrganigram the asset belongs to.
saltstring | nullSalt that determines the clone address.
symbolstring | nullToken symbol.
userBalancestring | nullBalance of the connected wallet, in the smallest unit.

AssetJson

An asset as plain JSON, to store or send it.

PropertyTypeDescription
addressstringContract address, or a predicted address while it is a draft.
chainIdstringChain the asset lives on.
decisionProcedurestring | nullProcedure authorized to settle this equity token's transfers.
imagestring | nullLogo URL.
initialSupplynumberSupply minted at deployment, in whole tokens.
isDeployedbooleanWhether the contract exists on chain.
kind'asset' | 'equity'asset for a plain token, equity for company shares whose transfers a procedure approves.
namestringToken name.
organigramIdstring | nullOrganigram the asset belongs to.
saltstring | nullSalt that determines the clone address.
symbolstringToken symbol.
userBalancestringBalance of the connected wallet, in the smallest unit.

ERC20_INITIAL_SUPPLY

Default supply minted for a new asset, in whole tokens.

Definition

const ERC20_INITIAL_SUPPLY = 10000000

Off-chain content and encryption

Contracts only store references. Metadata and documents live off-chain, and are referenced by CID references of the form og://workspace/<workspace>/<key>. Each version of a file is described by a manifest. Encrypted files use three levels of keys: a content key encrypts one file, a group key shared by the members of an access group wraps content keys, and the key pair of each member unwraps group keys. These functions run on the Web Crypto API of the user's device: keep private keys there, never send them to a server or log them.

EncryptedCidAccessGroup

The group whose members can decrypt a file.

PropertyTypeDescription
epochnumberGroup key generation, increased when membership changes.
scopeIdstringIdentifier of that workspace, organization, organ or procedure.
scopeTypeAccessGroupScopeTypeWhat the group is scoped to.

EncryptedCidManifest

Describes one version of an encrypted file: where its ciphertext is and how to get its key.

PropertyTypeDescription
accessGroupEncryptedCidAccessGroupGroup whose key unwraps the content key.
contentTypeScopeEnvelopeContentTypeWhat the file holds.
createdAtstringISO creation date.
encryptedContent{ cid: string; algorithm: typeof ENCRYPTION_ALGORITHM; iv: string; size: number; mime?: string; name?: string; }CID, algorithm, initialization vector, size, type and name of the ciphertext.
kindtypeof ENCRYPTED_CID_KIND | typeof FILE_VERSION_MANIFEST_KINDManifest format.
logicalKeystringStable name of the file.
previousManifestCidstringCID of the manifest of the previous version.
retentionStateScopeEnvelopeRetentionStateLifecycle state of this version.
scopeEnvelopeScopeEnvelopeCheckpointWorkspace checkpoint this version belongs to.
scopeRefScopeEnvelopeReferenceWorkspace the file belongs to.
signaturestringSignature of the author over the manifest.
signedByAddressstringAddress of the author.
version1Manifest format version.
wrappedContentKeyWrappedContentKeyContent key, encrypted with the group key.

EncryptionPublicKeySiweResource

An encryption public key read from a Sign-In with Ethereum message.

PropertyTypeDescription
addressstringAddress that signed in.
keyVersionnumberVersion of the key pair.
kindtypeof ENCRYPTION_PUBLIC_KEY_SIWE_RESOURCE_KINDResource format.
publicKeyJsonWebKeyPublic key, as a JSON Web Key.

ParsedCidRef

A CID reference split into its parts by parseCidRef().

PropertyTypeDescription
logicalKeystringStable name of the file within its workspace, whatever its version.
manifestCidstringPins the reference to one immutable file-version manifest when present.
scopeRefScopeEnvelopeReferenceWorkspace the file belongs to.

PublicFileVersionManifest

Describes one version of a file stored in clear on IPFS.

PropertyTypeDescription
accessGroupEncryptedCidAccessGroupGroup the file is shared with, if any.
contentTypeScopeEnvelopeContentTypeWhat the file holds.
createdAtstringISO creation date.
kindtypeof FILE_VERSION_MANIFEST_KINDManifest format.
logicalKeystringStable name of the file.
previousManifestCidstringCID of the manifest of the previous version.
publicContent{ cid: string; size: number; mime?: string; name?: string; }CID, size, type and name of the content.
retentionStateScopeEnvelopeRetentionStateLifecycle state of this version.
scopeEnvelopeScopeEnvelopeCheckpointWorkspace checkpoint this version belongs to.
scopeRefScopeEnvelopeReferenceWorkspace the file belongs to.
signaturestringSignature of the author over the manifest.
signedByAddressstringAddress of the author.
version1Manifest format version.

RecipientEncryptionKey

The public encryption key of a member, used to wrap a group key for them.

PropertyTypeDescription
addressstringEthereum address of the member.
keyVersionnumberVersion of the key pair.
publicKeyJsonWebKeyPublic key, as a JSON Web Key.

ScopeEnvelopeCheckpoint

A signed summary of every file of a workspace at one point in time.

PropertyTypeDescription
epochnumberAccess group generation at that time.
membershipHashstringHash of the members who had access.
rootHashstringHash of every file entry, from computeScopeEnvelopeRoot().

ScopeEnvelopeItem

The current version of one file in a workspace checkpoint.

PropertyTypeDescription
contentTypeScopeEnvelopeContentTypeWhat the file holds.
currentManifestCidstringCID of the manifest of its current version.
logicalKeystringStable name of the file.
previousManifestCidstringCID of the manifest of the previous version.
retentionStateScopeEnvelopeRetentionStateLifecycle state of this version.
updatedAtstringISO date of the last change.
versionnumberVersion number, starting at 1.

ScopeEnvelopeReference

The workspace a CID reference belongs to.

PropertyTypeDescription
scopeIdstringWorkspace identifier.
scopeTypeScopeEnvelopeScopeTypeKind of scope, always workspace.

StoredUserEncryptionKeyPair

The encryption key pair of the current user, as kept on their device.

PropertyTypeDescription
keyPairCryptoKeyPairWeb Crypto key pair.
keyVersionnumberVersion of the key pair.
publicKeyJsonWebKeyPublic key, as a JSON Web Key.

WrappedContentKey

A content key encrypted with a group key.

PropertyTypeDescription
algorithmtypeof ENCRYPTION_ALGORITHMWrapping algorithm.
ciphertextstringEncrypted content key, in base64.
ivstringInitialization vector, in base64.

WrappedGroupKey

A group key encrypted for one member, which only their private key can unwrap.

PropertyTypeDescription
algorithmtypeof GROUP_KEY_ALGORITHMWrapping algorithm.
ciphertextstringEncrypted group key, in base64.
ephemeralPublicKeyJsonWebKeyOne-time public key used for the key agreement.
ivstringInitialization vector, in base64.
recipientAddressstringEthereum address of the member.
recipientKeyVersionnumberVersion of the member key pair used.

AccessGroupScopeType

What an access group is scoped to: its members share one group key.

Definition

export type AccessGroupScopeType = 'workspace' | 'organization' | 'organ' | 'procedure' | 'certifiedProof';

EncryptedCidContentType

What a stored file holds, such as an organ entry or a proposal.

Definition

export type EncryptedCidContentType = 'entry' | 'proposal' | 'organMetadata' | 'procedureMetadata' | 'certifiedProof' | 'file' | string;

FileVersionManifest

One version of a stored file, public or encrypted.

Definition

export type FileVersionManifest = PublicFileVersionManifest | EncryptedCidManifest;

ScopeEnvelopeContentType

What the file behind a CID reference holds.

Definition

export type ScopeEnvelopeContentType = EncryptedCidContentType;

ScopeEnvelopeRetentionState

Lifecycle of a file version: current, replaced by a newer one, revoked or archived.

Definition

export type ScopeEnvelopeRetentionState = 'current' | 'superseded' | 'revoked' | 'archived';

ScopeEnvelopeScopeType

Scope of a CID reference. Only workspaces are supported.

Definition

export type ScopeEnvelopeScopeType = 'workspace';

bytesToArrayBuffer

Copy bytes into a standalone ArrayBuffer.

Signature

bytesToArrayBuffer: (value: ArrayBuffer | Uint8Array) => ArrayBuffer

bytesToText

Decode UTF-8 bytes into a string.

Signature

bytesToText: (value: ArrayBuffer | Uint8Array) => string

computeScopeEnvelopeRoot

Hash every file entry of a workspace into the root hash of a checkpoint.

Signature

computeScopeEnvelopeRoot: (items: Record<string, ScopeEnvelopeItem>) => Promise<string>

createEncryptionKeyVersion

Create a key version from a date, as a Unix timestamp in seconds.

Signature

createEncryptionKeyVersion: (timestamp?: number) => number

createEncryptionPublicKeyMessage

Build the message a user signs to register an encryption public key.

Signature

createEncryptionPublicKeyMessage: (address: string, publicKey: JsonWebKey, keyVersion: number) => string

createEncryptionPublicKeySiweResource

Encode an encryption public key as a Sign-In with Ethereum resource.

Signature

createEncryptionPublicKeySiweResource: (address: string, publicKey: JsonWebKey, keyVersion: number) => string

createFileVersionManifest

Describe a new version of an encrypted file.

Signature

createFileVersionManifest: (input: {
contentType: ScopeEnvelopeContentType;
scopeRef: ScopeEnvelopeReference;
logicalKey: string;
encryptedCid: string;
encryptedContentIv: string;
encryptedContentSize: number;
wrappedContentKey: WrappedContentKey;
previousManifestCid?: string | null;
retentionState?: ScopeEnvelopeRetentionState;
scopeEnvelope?: ScopeEnvelopeCheckpoint;
mime?: string;
name?: string;
signature?: string | null;
signedByAddress?: string | null;
createdAt?: Date | string;
}) => FileVersionManifest

createPublicFileVersionManifest

Describe a new version of a file stored in clear.

Signature

createPublicFileVersionManifest: (input: {
contentType: ScopeEnvelopeContentType;
scopeRef: ScopeEnvelopeReference;
logicalKey: string;
publicCid: string;
publicContentSize: number;
previousManifestCid?: string | null;
retentionState?: ScopeEnvelopeRetentionState;
scopeEnvelope?: ScopeEnvelopeCheckpoint;
mime?: string;
name?: string;
signature?: string | null;
signedByAddress?: string | null;
createdAt?: Date | string;
}) => PublicFileVersionManifest

createScopeEnvelopeCheckpoint

Create a workspace checkpoint.

Signature

createScopeEnvelopeCheckpoint: (input: {
epoch: number;
membershipHash: string;
rootHash: string;
}) => ScopeEnvelopeCheckpoint

createScopeEnvelopeItem

Describe the current version of one file for a workspace checkpoint.

Signature

createScopeEnvelopeItem: (input: {
logicalKey: string;
currentManifestCid: string;
contentType: ScopeEnvelopeContentType;
version?: number;
retentionState?: ScopeEnvelopeRetentionState;
previousManifestCid?: string;
updatedAt?: Date | string;
}) => ScopeEnvelopeItem

createScopeEnvelopeSignatureMessage

Build the message a member signs to vouch for a workspace checkpoint.

Signature

createScopeEnvelopeSignatureMessage: (input: {
scopeRef: ScopeEnvelopeReference;
checkpoint: ScopeEnvelopeCheckpoint;
items: Record<string, ScopeEnvelopeItem>;
previousEnvelopeCid?: string | null;
}) => string

decryptBytes

Decrypt bytes encrypted by encryptBytes().

Signature

decryptBytes: (encryptedBytes: ArrayBuffer | Uint8Array, key: CryptoKey, iv: string) => Promise<Uint8Array>

encryptBytes

Encrypt bytes with AES-GCM, and return the ciphertext with its initialization vector.

Signature

encryptBytes: (bytes: ArrayBuffer | Uint8Array, key: CryptoKey) => Promise<{
encryptedBytes: Uint8Array;
iv: string;
}>

exportUserPrivateKey

Export the private half of a user key pair as a JSON Web Key.

Only store the result encrypted, for example in a passkey vault.

Signature

exportUserPrivateKey: (keyPair: CryptoKeyPair) => Promise<JsonWebKey>

exportUserPublicKey

Export the public half of a user key pair as a JSON Web Key, to publish it.

Signature

exportUserPublicKey: (keyPair: CryptoKeyPair) => Promise<JsonWebKey>

formatCidRef

Build a CID reference, og://workspace/<workspace>/<key>, optionally pinned to one version.


formatCidRef({ scopeType: 'workspace', scopeId: workspaceId }, 'bylaws')

Signature

formatCidRef: (scopeRef: ScopeEnvelopeReference, logicalKey: string, manifestCid?: string) => string

generateContentKey

Generate the AES key that encrypts one file.

Signature

generateContentKey: () => Promise<CryptoKey>

generateGroupKey

Generate the AES key shared by the members of an access group.

Signature

generateGroupKey: () => Promise<CryptoKey>

generateUserEncryptionKeyPair

Generate the ECDH P-256 key pair a user decrypts their group keys with.

Keep the private key on the user's device: never send it to a server or log it.

Signature

generateUserEncryptionKeyPair: () => Promise<CryptoKeyPair>

getCrypto

Return the Web Crypto API, and throw where it is unavailable.

Signature

getCrypto: () => Crypto

getRandomIv

Generate a random 12-byte initialization vector for AES-GCM.

Signature

getRandomIv: () => Uint8Array

importExtractableUserPublicKey

Import a user public key from a JSON Web Key, keeping it exportable.

Signature

importExtractableUserPublicKey: (publicKey: JsonWebKey) => Promise<CryptoKey>

importUserPrivateKey

Import a user private key from a JSON Web Key.

Signature

importUserPrivateKey: (privateKey: JsonWebKey) => Promise<CryptoKey>

isCidRef

Tell whether a string is a CID reference.

Signature

isCidRef: (value?: string | null) => boolean

isEncryptedCidManifest

Tell whether a value is the manifest of an encrypted file.

Signature

isEncryptedCidManifest: (value: unknown) => value is EncryptedCidManifest

isFileVersionManifest

Tell whether a value is a file-version manifest, public or encrypted.

Signature

isFileVersionManifest: (value: unknown) => value is FileVersionManifest

isValidEncryptionKeyVersion

Tell whether a key version is already a valid Unix timestamp in seconds.

Signature

isValidEncryptionKeyVersion: (keyVersion: number) => boolean

normalizeEncryptionKeyVersion

Turn a key version into Unix seconds, accepting milliseconds, or return null if it is invalid.

Signature

normalizeEncryptionKeyVersion: (keyVersion: number) => number | null

parseCidRef

Split a CID reference into its parts, or return null if it is not one.

Signature

parseCidRef: (value?: string | null) => ParsedCidRef | null

parseEncryptionPublicKeySiweResource

Find the encryption public key of an address among Sign-In with Ethereum resources.

Signature

parseEncryptionPublicKeySiweResource: (resources: string[] | undefined, address: string) => EncryptionPublicKeySiweResource | null

unwrapContentKey

Decrypt a content key with a group key.

Signature

unwrapContentKey: (wrappedContentKey: WrappedContentKey, groupKey: CryptoKey) => Promise<CryptoKey>

unwrapGroupKey

Decrypt a group key with the private key of its recipient.

Signature

unwrapGroupKey: (wrappedGroupKey: WrappedGroupKey, recipientPrivateKey: CryptoKey) => Promise<CryptoKey>

wrapContentKey

Encrypt a content key with a group key.

Signature

wrapContentKey: (contentKey: CryptoKey, groupKey: CryptoKey) => Promise<WrappedContentKey>

wrapGroupKeyForRecipient

Encrypt a group key for one member, with their public key.

Signature

wrapGroupKeyForRecipient: (groupKey: CryptoKey, recipient: RecipientEncryptionKey) => Promise<WrappedGroupKey>

ENCRYPTED_CID_KIND

kind of manifests written before file versioning, still read for compatibility.

Definition

const ENCRYPTED_CID_KIND: "organigram.encrypted-cid.v1"

ENCRYPTION_ALGORITHM

Symmetric algorithm used for content and content keys: AES-256-GCM.

Definition

const ENCRYPTION_ALGORITHM: "A256GCM"

ENCRYPTION_PUBLIC_KEY_SIWE_RESOURCE_KIND

kind of the encryption public key a user publishes in a Sign-In with Ethereum message.

Definition

const ENCRYPTION_PUBLIC_KEY_SIWE_RESOURCE_KIND: "organigram.encryption-public-key.v1"

FILE_VERSION_MANIFEST_KIND

kind of a file-version manifest, public or encrypted.

Definition

const FILE_VERSION_MANIFEST_KIND: "organigram.file-version-manifest.v1"

GROUP_KEY_ALGORITHM

Algorithm used to wrap a group key for one member: ECDH on P-256, then AES-256-GCM.

Definition

const GROUP_KEY_ALGORITHM: "ECDH-P256+A256GCM"

Networks and deployments

The protocol contracts are deployed once per chain. These functions tell which chains are supported, where the contracts are, and at which address a new clone will be deployed.

getChainExplorerBaseUrl

Return the block explorer URL of a chain.

Signature

getChainExplorerBaseUrl: (chainId: string) => string | undefined

getConfiguredChain

Return the viem chain definition of a chain id.

Signature

getConfiguredChain: (chainId: string) => Chain | undefined

getDefaultChainId

Default network: Anvil when local deployments are loaded, Ethereum mainnet otherwise. Pass a chain id explicitly to use any other network.

Signature

getDefaultChainId: () => string

Returns

TypeDescription
stringThe default chain id.

getDeployment

Return the address of a protocol contract on a chain, and throw if it is not deployed there.

Signature

getDeployment: (chainId: string | number | bigint | null | undefined, deploymentName: ProtocolDeploymentName) => string

getHostUrl

URL of the Organigram app: NEXT_PUBLIC_HOST_URL, or the current page origin in a browser.

Signature

getHostUrl: (hostUrl?: string | undefined) => URL | null

getSupportedChainIds

List the chains the protocol is deployed on.

Signature

getSupportedChainIds: () => string[]

isLocalHost

Tell whether the app runs on a local host name.

Signature

isLocalHost: (hostUrl?: string) => boolean

isSupportedChainId

Tell whether the protocol is deployed on a chain.

Signature

isSupportedChainId: (chainId: string | number | bigint | null | undefined) => boolean

deployedAddresses

Addresses of the protocol contracts on each supported chain, by chain id.

Definition

const deployedAddresses: ProtocolDeployments

ContractName

Name of a protocol contract.

Definition

export type ContractName = 'Organ' | 'Asset' | 'EquityToken' | 'ERC20VoteProcedure' | 'VoteProcedure' | 'NominationProcedure' | 'OrganigramClient';

predictContractAddress

Predict the address of a clone deployed by the OrganigramClient.

The client binds each salt to the account deploying the clone, so only an address predicted with deployer is the address the clone will have. Without it, the result is merely a unique placeholder for a draft.

Signature

predictContractAddress: (input: {
type: Omit<ContractName, "OrganigramClient">;
chainId: string;
salt: string;
deployer?: string;
}) => string

Utilities

Small helpers used across the library and the Organigram app.

capitalize

Uppercase the first letter of a string.

Signature

capitalize: (s: string) => string

createRandom32BytesHexId

Generate a random 32-byte hex string, for example a salt.

Signature

createRandom32BytesHexId: () => `0x${string}`

handleJsonBigInt

A JSON.stringify replacer that writes bigints as strings ending in n.

Signature

handleJsonBigInt: (_key: string, value: unknown) => unknown

parseFiniteNumber

Parse a number, or return the fallback if the result is not finite.

Signature

parseFiniteNumber: (value: number | string | null | undefined, fallback: number) => number

Edit this page

On this page:

Installation
The client

Follow us:

© 2026 Organigram SAS

All Rights Reserved.