live · mainnetoc · docs
specs · api · guides
docs / documentation

@orangecheck/pledge-core


@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 swearerSigner whose address matches the canonical message's swearer.
  • Agent (SPEC §7.3): an agent signs on behalf of a principal under an OC Agent delegation. Pass viaDelegation with the delegation id and the agent's signer. The envelope carries via_delegation and agent_address but 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

ParameterType
inputCreatePledgeInput

Returns

Promise&lt;PledgeEnvelope>