Rayls Docs

Cross-chain transactions

In this section, we'll introduce you to the Rayls Protocol through hands-on examples, guiding you on how to harness its capabilities for private communication and asset transfers.

You'll learn to send arbitrary messages and teleport ERC20 tokens across blockchains, showcasing the protocol's versatility and ease of use. These examples are designed to kickstart your journey, offering a clear path to integrating Rayls into your blockchain projects.

First, let's get started with the pre-requisites and installation. Then we will work through some examples.

Development pre-requisites

You should first be familiar with writing and deploying contracts to your desired blockchains. This involves understanding the specific smart contract language and the deployment process for those chains.

Let's create a new Hardhat project

To install it, you need to create an npm project by going to an empty folder, running npm init, and following its instructions. You can use another package manager, like yarn, but we recommend you use npm 7 or later, as it makes installing Hardhat plugins simpler.

Once your project is ready, you should run:

npm install --save-dev hardhat

And now you create a new Hardhat project by running:

npx hardhat init

And then select either "Create a JavaScript project" or "Create a TypeScript project".


Installation

The Rayls Protocol NPM package

To use Rayls SDK, you need to interact with Rayls specific contracts from the @rayls/contracts
NPM package.

In your hardhat project, include the Rayls Protocol SDK package.

npm i @rayls/contracts

Once installed, you can use the contracts in the library by importing them.
Example:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {RaylsApp} from "@rayls/contracts/RaylsApp.sol";

contract HelloWorldContract is RaylsApp {
    constructor(
        address _endpoint
    ) RaylsApp(_endpoint, msg.sender) {}
}

Infinite possibilities...

The Rayls protocol is highly flexible, so we'll begin by giving you a brief overview of its capabilities. However, it's designed to be adaptable, allowing you to customize and extend it to suit your specific needs.

📘

You MUST have the Rayls Endpoint contract installed in your Privacy Ledger.

Usage

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {RaylsApp} from "@rayls/contracts/RaylsApp.sol";

contract HelloWorldContract is RaylsApp {
    constructor(
        address _endpoint
    ) RaylsApp(_endpoint, msg.sender) {}
}