> ## Documentation Index
> Fetch the complete documentation index at: https://trust-link-tsn.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# buildLinkSocialIdentityInstruction — Link social identity

> Encode an encrypted social identity link for a TIN registry transaction without exposing the plaintext identity value.

## What it does

This helper builds the single Solana instruction that links encrypted social identity data to a TIN registry.

## How the flow works

<Steps>
  <Step title="Caller invokes the function">The caller provides the owner, registry PDA, identity type, encryption nonce, ciphertext, and optional metadata.</Step>
  <Step title="Validation">The SDK encodes the supplied strings and byte arrays; account and signature checks occur on chain.</Step>
  <Step title="Main work">It serializes the fields with instruction tag `9` and marks the owner and registry accounts correctly.</Step>
  <Step title="Result">The caller receives a `TransactionInstruction` to add to an owner-signed Solana transaction.</Step>
</Steps>

## Signature

```ts theme={null}
export function buildLinkSocialIdentityInstruction(params: {
  owner: PublicKey; registry: PublicKey; identityType: TinSocialIdentityType;
  label?: string; nonce: Uint8Array; ciphertext: Uint8Array; metadata?: string;
  programId?: PublicKey | string | null;
}): TransactionInstruction
```

<ParamField path="owner" type="PublicKey" required>Owner signer and writable account.</ParamField>
<ParamField path="registry" type="PublicKey" required>TIN registry PDA.</ParamField>
<ParamField path="identityType" type="string" required>Identity provider type.</ParamField>
<ParamField path="label" type="string" required={false}>Optional label; defaults to an empty string.</ParamField>
<ParamField path="nonce" type="Uint8Array" required>Encryption nonce.</ParamField>
<ParamField path="ciphertext" type="Uint8Array" required>Encrypted identity value.</ParamField>
<ParamField path="metadata" type="string" required={false}>Metadata JSON; defaults to `{}`.</ParamField>

## Result and errors

Returns one instruction. Runtime account ownership, signer, and registry-state failures are enforced by the TIN program.

```ts theme={null}
transaction.add(buildLinkSocialIdentityInstruction(params));
```

Source: [`tins.ts:907-931`](https://github.com/Trustlink-Labs/TSN-Protocol/blob/main/tsn-protocol/sdks/tsn-sdk/src/tins.ts#L907-L931)
