Deploying smart contracts


Overview

In the Rayls ecosystem, deploying smart contracts within a Rayls Privacy Node Privacy Ledger (PL) has different routes, such as using the Rayls Custody or Direct Contact Privacy Ledger. This guide outlines the available options and best practices for deploying contracts in the Rayls Privacy Node.


Deployment Options

Here are the different routes to deploy a smart contract within the Rayls Privacy Node:

Via Privacy Ledger

To deploy a smart contract using direct contact with the Rayls Privacy NodePrivacy Ledger you will need to set up a JSON-RPC (JRPC) communication, following these steps:

Pre-requisites:

  • Access to Rayls Privacy Node Privacy Ledger: Ensure you are connected to the Privacy Ledger node through its RPC endpoint (e.g., <http://your-ledger-url:8545).>)
  • Compiled Smart Contract: Have your smart contract’s bytecode ready (compiled from Solidity via Remix, Truffle, etc.).
  • Authorized Account: Ensure you have access to your authorized account on the Rayls Privacy Ledger to deploy the contract.

Step-by-Step

1. Compile the Smart Contract:

Use Remix or Truffle to compile your smart contract written in Solidity. The output includes:

  • Bytecode: The compiled smart contract code in hexadecimal form (starts with 0x).
  • ABI (Application Binary Interface): Optional, for interacting with the contract post-deployment.

2. Prepare the Deployment Transaction:

Create the JSON-RPC request to deploy the smart contract on the Rayls Privacy Node Privacy Ledger.

Example JSON-RPC request:

{  
  "jsonrpc": "2.0",  
  "method": "eth_sendTransaction",  
  "params": [{  
    "from": "0xYourAccountAddress",  // The address deploying the contract  
    "data": "0xYourContractBytecode", // The compiled contract bytecode  
  }],  
  "id": 1  
}

3. Send the Deployment Transaction:

Send the deployment transaction using curl or any JSON-RPC client. Here’s an example using curl:

curl -X POST http\://your-ledger-url:8545  
-H "Content-Type: application/json"  
--data '{  
  "jsonrpc":"2.0",  
  "method":"eth_sendTransaction",  
  "params":[{  
    "from":"0xYourAccountAddress",  
    "data":"0xYourContractBytecode",  
  }],  
  "id":1  
}'

This will send the contract bytecode to the Rayls Privacy Node Privacy Ledger for deployment.

4. Monitor the Transaction:

After submitting the transaction, monitor its status to ensure the contract is successfully deployed. Use the transaction hash (txHash) returned from the previous step to track it. Monitoring can be done via JSON-RPC request or via your Privacy Ledger block explorer.

Example JSON-RPC request to get the transaction receipt:

{  
  "jsonrpc": "2.0",  
  "method": "eth_getTransactionReceipt",  
  "params": ["0xYourTransactionHash"],  
  "id": 1  
}

Use curl to send the request:

curl -X POST  
http\://your-ledger-url:8545  
-H "Content-Type: application/json"  
--data '{  
  "jsonrpc":"2.0",  
  "method":"eth_getTransactionReceipt",  
  "params":["0xYourTransactionHash"],  
  "id":1  
}'

In the response, look for the contractAddress field to confirm that the contract has been successfully deployed on the Rayls Privacy Node Privacy Ledger.


Conclusion

Deploying smart contracts on a Rayls Privacy Node Privacy Ledger is straightforward, with direct deploying contacts in Rayls Privacy Node Privacy Ledger (JSON-RPC requests) serving as the primary tools. Rayls also enables easy integration from third-party tools, such as digital assets platforms and tokenization platforms that can offer more flexibility for deploying use-case specific smart contracts.

By leveraging the appropriate tools, developers can efficiently deploy and manage contracts within the Rayls Privacy Node, ensuring they are fully integrated into the Rayls ecosystem.