@orangecheck/pledge-core / createPledge
Function: createPledge()
function createPledge(input: CreatePledgeInput): Promise<PledgeEnvelope>;
Defined in: pledge-core/src/pledge.ts:49
Build, validate, and sign a pledge envelope.
Two signing paths:
- Direct (most common): swearer signs themselves. Pass
swearerSignerwhoseaddressmatches the canonical message's swearer. - Agent (SPEC §7.3): an agent signs on behalf of a principal under an
OC Agent delegation. Pass
viaDelegationwith the delegation id and the agent's signer. The envelope carriesvia_delegationandagent_addressbut those fields are NOT in the canonical message — they're verifier-checked claims, not signed bytes.
Returns the fully-formed envelope. Throws PledgeError on validation failure, never on signature failure (signing is the caller's adapter).
Parameters
| Parameter | Type |
|---|---|
input | CreatePledgeInput |
Returns
Promise<PledgeEnvelope>