Demos Network Specifications
  • Introduction
    • What is Demos Network
    • Demos Network Architecture
  • FAQ
  • Cookbook
    • Project setup
      • Run the project (MacOS)
      • Run the project (Windows)
        • WSL 2 Setup on Windows (10 and 11 only)
        • Issue Troubleshooting
      • Run the project (Ubuntu)
  • SDK
    • Getting Started
    • WebSDK
      • Authentication
        • FIDO2 Passkeys
          • Under the Hood: FIDO2 Passkeys
      • NodeCalls
      • Transactions
        • Creating a transaction
        • Signing a transaction
        • Broadcasting a transaction
      • L2PS SDK
        • The l2ps module
        • Interacting with the L2PS
        • L2PS Messaging System
      • Instant Messaging
        • What is the Instant Messaging Protocol?
        • Architecture Overview
        • Encryption
        • Quickstart
        • Message Types
        • API Reference
        • FAQ
    • Cross Chain
      • General layout of the XM SDKs
      • EVM
      • BTC
      • Solana
      • MultiversX (EGLD)
      • NEAR
      • IBC
      • TON
      • XRPL
      • The XMScript
      • Identities
    • Demoswork
    • Cookbook
      • Demoswork
        • Creating work steps
        • Conditional Operation
        • Base Operation
        • Signing and broadcasting
      • Transactions
        • Crosschain Transaction
        • Native Transactions
      • SWAP
        • Crosschain SWAP
    • Web2
      • Quick Start
      • DAHR API Reference
        • Types
      • Making Requests
      • Identities
        • Twitter
        • GitHub
    • API Reference
    • Bridges
      • Rubic Bridge Test
    • Post Quantum Cryptography
  • Backend
    • Internal Mechanisms
      • Network Time Synchronization
      • Cross Context Identities
    • Global Change Registry
      • GCR Structure
      • How is GCR Synced?
    • Consensus Mechanism
      • Unparalleled Scalability
      • Decentralization in PoR-BFT
      • Enhanced Security
      • Comparative Advantage
      • Addressing Potential Criticisms
      • Conclusion
    • Communications Stack
    • L2PS (Subnet) Framework
      • How are L2PS transactions handled?
    • Miscellaneous
      • Browsing the Postgres DB via psql
    • Bridges
      • Rubic Bridge
    • Developers Testbed
      • Setting up the environment
      • Setting up the repository
      • Installing dependencies
      • Node Configuration
      • Running the node
  • Frontend
    • Demos Providers Discovery Mechanism
Powered by GitBook
On this page
  • 0. Imports
  • 1. Creating the EVM payload
  • 2. Converting the payload into an XMScript
  • 3. Creating a DEMOS instance
  • 4. Converting the XMScript to a Demos transaction
  • 5. Broadcasting to a Demos node
  1. SDK
  2. Cookbook
  3. Transactions

Crosschain Transaction

You can perform a crosschain transaction via the DEMOS network with the help of the DEMOS sdk.

Here is how you can send tokens on Sepolia testnet via DEMOS using the sdk:

0. Imports

The following imports will be needed to create the transaction.

import {
  Demos,
  prepareXMPayload,
  prepareXMScript,
} from "@kynesyslabs/demosdk/websdk";

import { EVM } from "@kynesyslabs/demosdk/xm-websdk";

1. Creating the EVM payload

You can create the payload for Sepolia via the crosschain module of the sdk as follows:

const sepolia_rpc = "https://rpc.ankr.com/eth_sepolia"
const evm = await EVM.create(sepolia_rpc);
await evm.connectWallet(
  "e0a00e307....." // fill in with your sepolia private key
);

const evm_tx = await evm.preparePay(
    "0xda3ea78Af43E6B1c63A08cD0058973F14e5556b0",
    "0.000000001",
)

The evm_tx will be a signed transaction to move 0.000000001 Sepolia ETH from the connected wallet to0xda3ea78Af43E6B1c63A08cD0058973F14e5556b0.

2. Converting the payload into an XMScript

const xmscript = prepareXMScript({
  chain: "eth",
  subchain: "sepolia",
  signedPayloads: [evm_tx],
  type: "pay",
});

The xmscript will be embedded into a DEMOS transaction and sent to the DEMOS network in the upcoming sections.

3. Creating a DEMOS instance

A DEMOS identity is needed to sign the outgoing DEMOS transaction.

const demos = new Demos()

const demos_rpc = "https://demosnode.discus.sh";
await demos.connect(demos_rpc);

const mnemonic = demos.newMnemonic()
await demos.connectWallet(mnemonic)

4. Converting the XMScript to a Demos transaction

You can convert the xmscript into a DEMOS transaction by calling prepareXMPayload and passing the xmscript and the Demos instance.

const tx = await prepareXMPayload(xmscript, demos);

The tx will be a signed Demos transaction containing the Sepolia tx.

5. Broadcasting to a Demos node

You can now broadcast the transaction as shown:

// confirm tx
const validityData = await demos.confirm(tx);
console.log("validityData", validityData);

// execute
const res = await demos.broadcast(validityData);
console.log("res", res);
PreviousTransactionsNextNative Transactions

Last updated 11 days ago

The contains information that helps a DEMOS node understand what to do with a signed crosschain payload.

XMScript