Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Types & Interfaces

TypeScript type definitions used in the SDK.

Core Types

PubKey

interface PubKey {
    x: bigint;
    y: bigint;
}

Elliptic curve point representing a public key.

TongoAddress

type TongoAddress = string & { __type: "tongo" };

Base58-encoded public key string.

CipherBalance

interface CipherBalance {
    L: ProjectivePoint;
    R: ProjectivePoint;
}

ElGamal ciphertext for encrypted balances.

AEBalance

interface AEBalance {
    c0: bigint;
    c1: bigint;
    c2: bigint;
}

ChaCha20-encrypted hint for faster decryption.

Account Types

AccountState

interface AccountState {
    balance: bigint;
    pending: bigint;
    nonce: bigint;
}

Decrypted account state.

RawAccountState

interface RawAccountState {
    balance: CipherBalance;
    pending: CipherBalance;
    audit?: CipherBalance;
    nonce: bigint;
    aeBalance?: AEBalance;
    aeAuditBalance?: AEBalance;
}

Encrypted account state from contract.

Operation Parameter Types

FundDetails

interface FundDetails {
    amount: bigint;
}

TransferDetails

interface TransferDetails {
    amount: bigint;
    to: PubKey;
}

WithdrawDetails

interface WithdrawDetails {
    to: string;      // Starknet address
    amount: bigint;
}

RagequitDetails

interface RagequitDetails {
    to: string;  // Starknet address
}

Event Types

AccountEvents

type AccountEvents =
    | AccountFundEvent
    | AccountTransferOutEvent
    | AccountTransferInEvent
    | AccountRolloverEvent
    | AccountWithdrawEvent
    | AccountRagequitEvent;

AccountFundEvent

interface AccountFundEvent {
    type: 'fund';
    tx_hash: string;
    block_number: number;
    nonce: bigint;
    amount: bigint;
}

AccountTransferOutEvent

interface AccountTransferOutEvent {
    type: 'transferOut';
    tx_hash: string;
    block_number: number;
    nonce: bigint;
    amount: bigint;
    to: string;  // Tongo address
}

AccountTransferInEvent

interface AccountTransferInEvent {
    type: 'transferIn';
    tx_hash: string;
    block_number: number;
    nonce: bigint;
    amount: bigint;
    from: string;  // Tongo address
}

Utility Functions

derivePublicKey

function derivePublicKey(privateKey: bigint): PubKey

pubKeyAffineToBase58

function pubKeyAffineToBase58(pub: PubKey): TongoAddress

pubKeyBase58ToAffine

function pubKeyBase58ToAffine(b58string: string): { x: bigint; y: bigint }