Rayls DocsRayls Custody API
Rayls Docs

Sending Intra-Rayls Privacy Node Transactions

Overview

In the Rayls ecosystem, there are two main types of transactions:

  1. Internal transactions within a single Rayls Privacy Node Ledger (PL).
  2. Cross-chain transactions between different Rayls Privacy Nodes via the Subnet Hub (link to cross-chain transactions page).

This page focuses on internal transactions within a single Rayls Privacy Node and guides you through the process of sending transactions using various methods, including Rayls Custody Light APIs.

Prerequisites

  • Set up a wallet or custody account within the Rayls Privacy Node.
  • Have access to the Rayls Privacy Node Ledger’s RPC endpoint or the Rayls Custody Light APIs.
  • Have a sufficient token balance in your wallet for the transaction.

Executing Internal Transactions in a Rayls Privacy Node Ledger


1. Direct Contact to the Rayls Privacy Node Ledger Transaction Execution

Rayls is fully EVM-compatible, therefore it supports Ethereum-like transaction execution, allowing developers familiar with Ethereum to use tools like Ethers.js and Web3.js.

Example Transaction Using Ethers.js:

const { ethers } = require('ethers');  
const provider = new ethers.providers.JsonRpcProvider('<Privacy-Ledger-Endpoint>');

const privateKey = '<Your-Private-Key>';  
const wallet = new ethers.Wallet(privateKey, provider);

async function sendTransaction() {  
    const tx = {  
        to: '<Recipient-Address>',  
        value: ethers.utils.parseEther('1.0')  
    };
const transaction = await wallet.sendTransaction(tx);
await transaction.wait();
console.log('Transaction successful:', transaction);
}

sendTransaction();

2. Using Rayls Custody Light APIs

Rayls provides a set of APIs through its Custody Light out-of-the-box solution, which allows for seamless transaction execution, token management, and address management within a Rayls Privacy Node Ledger. These optional APIs handle everything from authentication to transaction creation and monitoring.

To send a transaction within a Rayls Privacy Node Ledger using the Rayls Custody Light API, follow the steps below.

Read more about the Custody Light APIs in the docs page.


Step-by-Step (via Rayls Custody)


1. Authenticate and Obtain a Token

Before making any API calls, you need to authenticate and obtain an access token via the POST /api/auth. This token is used to authorize subsequent API calls. Once authenticated, use the Rayls Custody API to create and send a transaction.


2. Check Token Balance

Ensure you have sufficient balance of the token you intend to send, and utilize the GET /api/token/{id}/balance/{walletId}.


3. Send a Transaction

To securely transfer tokens from one wallet to another within the Rayls Privacy Node Ledger use the POST /api/transaction/transfer-token. Here is an example API Call for sending a internal transaction:

Request:

POST <https://api.rayls.com/api/transaction/transfer-token>  
Content-Type: application/json  
Authorization: Bearer <your-access-token>

{  
    "from": "<your-wallet-id>",  
    "to": "<recipient-wallet-id>",  
    "token": "<token-id>",  
    "value": "1000000000000000000"  
}

Response:

{  
    "transactionHash": "<tx-hash>",  
    "status": "pending"  
}

4. Monitor the Transaction

Once the transaction is sent, you can monitor its status and track its progress through the Rayls Privacy Node Ledger block explorer or via the GET /api/transaction/{hash}.

Read more about monitoring Rayls Privacy Node Ledger transaction in this doc page.

Follow the methods shared in this guide to send internal transactions within the Rayls Privacy Node efficiently and securely. This step-by-step instructions will ensure smooth execution of transactions within the Rayls ecosystem.

For cross-chain transactions details, refer to the Sending Teleports documentation page.