npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@xrplevm/xchain-sdk

v0.1.0

Published

Cross-chain SDK to enable developers bridge assets between XRPL and XRPL EVM Sidechain programatically.

Downloads

5

Readme

@xrplevm/xchain-sdk

Cross-chain SDK to enable developers to bridge assets between XRPL and the XRPL EVM Sidechain programmatically.

Table of Contents

Installation

npm install @xrplevm/xchain-sdk
# or
pnpm add @xrplevm/xchain-sdk
# or
yarn add @xrplevm/xchain-sdk

Features

  • Bridge assets between XRPL and XRPL EVM Sidechain
  • Supports native XRP, issued assets, and EVM tokens
  • Simple configuration for multiple networks (mainnet, testnet, devnet)
  • TypeScript support

Core API

The Bridge class is the main entry point for interacting with the SDK. It encapsulates the logic for cross-chain operations between XRPL and the XRPL EVM sidechain. You typically create an instance of this class using the static fromConfig method, providing network details and any necessary overrides.

Bridge.fromConfig(network, overrides)

Create a bridge instance with network defaults and optional overrides.

  • network: devnet | testnet | mainnet
  • overrides (optional):
    • xrpl: override XRPL RPC, gateway, Chain ID, or add a seed
    • xrplevm: override XRPL-EVM RPC, gateway, Chain ID, or add a private key

It will expect you to input at least the private key or seed from the destination chain to build the wallet to sign and submit the transactions.

bridge.transfer(asset, amount, options?)

Perform a cross-chain transfer. The direction (XRPL→EVM or EVM→XRPL) is inferred from the asset type.

Note:
The options object differs depending on the transfer direction. The most relevant options are:

  • XRPL → EVM:

    • gasFeeAmount (optional): Custom gas fee for the EVM transaction (default from config)
    • (See XrplTransferOptions for all options)
  • EVM → XRPL:

    • interchainGasValue (optional): Gas value (in wei, as a string) for the interchain part of the transfer. Defaults to "0" if not provided.
    • gasValue (optional): Gas price (in wei, as a string) for the EVM transaction.
    • gasLimit (optional): Gas limit (as a string) for the EVM transaction.
    • (See XrplEvmTransferOptions for all options)

Refer to the generated TypeScript definitions for the full list of supported options and types for each direction:

bridge.transfer(
  asset: BridgeAsset,         // EvmAsset or Xrp/XrplAsset
  amount: number,             // e.g. 1.5
  options: {
    destinationAddress: string;    // recipient on target chain
    doorAddress?: string;         // custom gateway contract
    gasValue?: string;            // XRPL→EVM only
  }
);

bridge.callContract(asset, destinationContractAddress, payload)

Execute a smart contract function on the EVM sidechain, initiated from XRPL, along with transferring an XRPL asset (either native XRP or an issued asset). This allows for more complex cross-chain interactions beyond simple transfers.

  • asset: The XrpAsset or XrplIssuedAsset to be transferred from XRPL.
  • destinationContractAddress: The address of the smart contract on the EVM sidechain to call.
  • payload: Hex-encoded data representing the function call and its arguments for the destination contract.

Refer to the Bridge class source code (src/bridge/bridge.ts) for the exact method signature and return types.

Configuration

The SDK provides sane defaults for all networks (RPC endpoints, Axelar gateway & token service addresses, chain IDs). You can override any value in fromConfig:

Bridge.fromConfig("mainnet", {
    xrplevm: {
        providerUrl: "https://my.custom.rpc",
        privateKey: process.env.EVM_KEY,
    },
    xrpl: {
        providerUrl: "wss://custom.xrpl.rpc",
        keyOrSeed: process.env.XRPL_SEED,
    },
});

Configuration Structure

At the core, the SDK uses the following configuration interfaces:

  • AxelarChainConfig :

    • providerUrl: RPC endpoint for the EVM-compatible chain
    • chainId: Chain ID of the EVM network
    • gatewayAddress: Axelar Gateway contract address
    • interchainTokenServiceAddress: Axelar Interchain Token Service contract address
  • BridgeConfig :

    • xrpl: XRPL chain configuration, extends AxelarChainConfig with seed.
    • xrplevm: EVM sidechain configuration extends AxelarChainConfig with privateKey
  • BridgeConfigOptions: Allows you to override any part of the default config for either chain.

Required Secrets

The configuration enforces that you provide at least the secret (seed or private key) for the source chain. This is required to build the wallet and sign transactions. For XRPL, provide a seed; for EVM, provide a privateKey.

Flow: How Configuration is Used

  • Bridge.fromConfig builds the provider for both chains using the configuration (with defaults or your overrides).
  • The wallet is built from the secret of the source chain, enabling signing and sending transactions.
  • The destination chain provider is also initialized, but the wallet is only required for the source chain.

Errors

The SDK provides descriptive error classes and codes to help you handle issues programmatically. Most errors thrown are subclasses of BridgeError or chain-specific errors like XrplEvmError.

BridgeErrorCodes

  • MISSING_WALLET_SECRET — Wallet secret or private key not provided
  • INVALID_CONFIG — Configuration is invalid or incomplete

XrplEvmErrorCodes

  • NO_EVM_SIGNER — EVM signer is missing
  • RPC_UNAVAILABLE — EVM RPC provider is unavailable
  • TX_NOT_MINED — EVM transaction was not mined

XrplErrorCodes

  • INVALID_SEED — Invalid XRPL wallet seed provided
  • NO_RPC_FOR_XRPL_SOURCE — No RPC URL provided for XRPL source

You can catch and inspect these errors to provide better UX or debugging information:

try {
  await bridge.transfer(...);
} catch (err) {
  if (err instanceof BridgeError) {
    console.error('Bridge error:', err.code, err.message);
  }
}

Examples

See the examples/ directory for sample scripts:

  • Transfer XRP from XRPL to EVM
  • Transfer EVM tokens to XRPL
  • Call contracts with token transfers