1.0.0 • Published 7 months ago

@realiotech/client-signer v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

Client Signer SDK

A client side cross-chain message signing SDK for Realio, supporting multiple blockchain protocols.

Installation

npm install @realiotech/client-signer

Usage

import { createSigner, PROTOCOL_NAMES } from 'client-signer';

const signer = createSigner({
  protocol: PROTOCOL_NAMES.BITCOIN,
  mnemonic: 'your mnemonic here',
  options: { mainnet: true },
});

const result = await signer.signTransaction(unsignedTx);

Supported Protocols

  • Bitcoin
  • EVM
  • Tendermint
  • Stellar
  • Algorand
  • Solana

API Integration

This SDK is tightly coupled with Realio's core transaction API. Currently it supports signing transactions from the send-token/unsigned API. All other APIs or data formats are not tested and not guaranteed to work.

Supported APIs

Input Data Format

The SDK expects transaction data to be in the format provided by Realio's core transaction API. This means:

  1. The input transaction data must be obtained by calling the core API's transaction creation methods
  2. The signer will not validate or modify the transaction structure - it only handles the signing process

API Reference

createSigner

function createSigner<T extends ProtocolOptions>(options: CreateSignerOptions<T>): Signer;

Parameters

  • options: Configuration object containing:
    • protocol: The blockchain protocol to use (from PROTOCOL_NAMES)
    • mnemonic: BIP39 mnemonic phrase
    • options: Protocol-specific options (optional)

Returns

A Signer instance with a signTransaction method.

Signer Interface

interface Signer {
  signTransaction(tx: string): Promise<SignedTx>;
}

Protocol Options

BitcoinOptions

interface BitcoinOptions {
  mainnet: boolean; // true for mainnet, false for testnet
}

StellarOptions

interface StellarOptions {
  mainnet: boolean; // true for mainnet, false for testnet
}

TendermintOptions

interface TendermintOptions {
  chain: Chain;
  sender: Sender;
}

Examples

Bitcoin Transaction Signing

import { createSigner, PROTOCOL_NAMES } from 'client-signer';

const signer = createSigner({
  protocol: PROTOCOL_NAMES.BITCOIN,
  mnemonic: 'your mnemonic here',
  options: { mainnet: false }, // Required: true for mainnet, false for testnet
});

const result = await signer.signTransaction(unsignedPsbtHex);

EVM Transaction Signing

import { createSigner, PROTOCOL_NAMES } from 'client-signer';

const signer = createSigner({
  protocol: PROTOCOL_NAMES.EVM,
  mnemonic: 'your mnemonic here',
});

const result = await signer.signTransaction(unsignedTxHex);

Tendermint Transaction Signing

import { createSigner, PROTOCOL_NAMES } from 'client-signer';

const signer = createSigner({
  protocol: PROTOCOL_NAMES.TENDERMINT,
  mnemonic: 'your mnemonic here',
  options: {
    chain: {
      chainId: 3300,
      cosmosChainId: 'realionetwork_3300-4',
    },
    sender: {
      accountAddress: 'realio...',
      pubkey: 'AzUx...',
      accountNumber: 124,
      sequence: 1,
    },
  },
});

const result = await signer.signTransaction(unsignedTx);

Stellar Transaction Signing

import { createSigner, PROTOCOL_NAMES } from 'client-signer';

const signer = createSigner({
  protocol: PROTOCOL_NAMES.STELLAR,
  mnemonic: 'your mnemonic here',
  options: { mainnet: false }, // Required: true for mainnet, false for testnet
});

const result = await signer.signTransaction(unsignedXdr);

Algorand Transaction Signing

import { createSigner, PROTOCOL_NAMES } from 'client-signer';

const signer = createSigner({
  protocol: PROTOCOL_NAMES.ALGORAND,
  mnemonic: 'your mnemonic here',
});

const result = await signer.signTransaction(unsignedTxBase64);

Solana Transaction Signing

import { createSigner, PROTOCOL_NAMES } from 'client-signer';

const signer = createSigner({
  protocol: PROTOCOL_NAMES.SOLANA,
  mnemonic: 'your mnemonic here',
});

const result = await signer.signTransaction(unsignedTxBase64);

Development

# Install dependencies
npm install

# Run tests
npm test

# Build
npm run build

Tools

  • tsup: TypeScript bundler
  • Vitest: Testing framework
  • ESLint: Code linting
  • Prettier: Code formatting