Skip to main content

Class: EmbeddedThruChain

Defined in: EmbeddedThruChain.ts:19

Thru chain adapter that delegates all signing operations to the KEA Wallet iframe via the postMessage protocol. Implements the IThruChain interface.

Remarks

You typically don't construct this directly — access it via EmbeddedProvider.thru or BrowserSDK.thru.

Implements

  • IThruChain

Connection

connect()

connect(): Promise<{
publicKey: string;
}>;

Defined in: EmbeddedThruChain.ts:48

Connect to the wallet and return the Thru public key.

Returns

Promise<{ publicKey: string; }>

Object containing the Thru account public key

Throws

Error if no Thru-type address is found in the connection result

Example

const { publicKey } = await provider.thru.connect();
console.log('Thru public key:', publicKey);

Implementation of

IThruChain.connect

disconnect()

disconnect(): Promise<void>;

Defined in: EmbeddedThruChain.ts:64

Disconnect from the wallet.

Returns

Promise<void>

Implementation of

IThruChain.disconnect

Chain

getSigningContext()

getSigningContext(): Promise<ThruSigningContext>;

Defined in: EmbeddedThruChain.ts:93

Retrieve the signing context (fee payer and signer public keys) from the wallet.

The selected account is the managed wallet account shown to the user. The fee payer / signer can differ when the wallet routes transactions through an embedded manager profile.

Returns

Promise<ThruSigningContext>

The signing context with fee payer and signer public keys

Throws

Error if the wallet is not connected

Remarks

Always use feePayerPublicKey from the signing context when building the transaction — do not assume the selected account is the fee payer.

Example

const ctx = await provider.thru.getSigningContext();
// Use ctx.feePayerPublicKey when building the transaction,
// NOT the selected account address.
console.log('Fee payer:', ctx.feePayerPublicKey);
console.log('Signer:', ctx.signerPublicKey);

Implementation of

IThruChain.getSigningContext

signTransaction()

signTransaction(serializedTransaction: string): Promise<string>;

Defined in: EmbeddedThruChain.ts:132

Sign a transaction via the wallet iframe. Opens the wallet UI for user confirmation and returns the signed transaction.

Parameters

ParameterTypeDescription
serializedTransactionstringBase64-encoded serialized transaction to sign

Returns

Promise<string>

The signed transaction as a base64 string — ready for direct submission

Throws

Error if the wallet is not connected or the payload is invalid

Remarks

The returned bytes are canonical raw transaction bytes. Submit them directly — do not prepend, append, or reorder signature bytes.

Example

// Encode the signing payload as base64
const payloadBase64 = btoa(String.fromCharCode(...transaction.toWireForSigning()));
const signedBase64 = await provider.thru.signTransaction(payloadBase64);
// Submit the signed bytes directly
const signature = await thru.transactions.send(base64ToBytes(signedBase64));

Implementation of

IThruChain.signTransaction

Other

connected

Get Signature

get connected(): boolean;

Defined in: EmbeddedThruChain.ts:30

Whether the underlying provider is currently connected.

Returns

boolean

Implementation of

IThruChain.connected