Deploying smart contracts

Overview

Deploying smart contracts in a Rayls Sovereign ledger can be done by several routes, including Rayls Custody and direct contact with the Sovereign ledger. This guide sets out the available options and the recommended practice for each.


Deployment Options

Here are the routes for deploying a smart contract in a Rayls Sovereign ledger.

Via the Sovereign ledger

To deploy a smart contract by contacting the Sovereign ledger directly, you will need to set up JSON-RPC (JRPC) communication, following these steps.

Pre-requisites:

  • Access to the Sovereign ledger: Ensure you are connected to the Sovereign ledger through its RPC endpoint (for example, http://your-ledger-url:8545).
  • Compiled Smart Contract: Have your smart contract's bytecode ready, compiled from Solidity via Remix, Truffle or a comparable tool.
  • Authorised Account: Ensure you have access to your authorised account on the Sovereign 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 after deployment.

2. Prepare the Deployment Transaction:

Create the JSON-RPC request to deploy the smart contract in the Sovereign 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 is 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 sends the contract bytecode to the Sovereign ledger for deployment.

4. Monitor the Transaction:

After submitting the transaction, monitor its status to confirm the contract has deployed. Use the transaction hash (txHash) returned from the previous step to track it. Monitoring can be done via a JSON-RPC request or via your 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 deployed in the Sovereign ledger.


Conclusion

JSON-RPC requests sent directly to the Sovereign ledger are the primary route for deploying contracts in a Rayls Sovereign ledger. Rayls also supports integration from third-party tools, including digital asset platforms and tokenisation platforms, which offer more flexibility for deploying use-case-specific contracts.

One difference from public Ethereum is worth knowing before you design a contract. The Sovereign ledger raises the contract bytecode limit from the 24 KB of EIP-170 to 1 MB, and the init code limit from 48 KB to 2 MB, so complex financial logic, cross-chain routing and proof verification can sit in a single contract rather than being split across several or hidden behind proxy patterns adopted purely for size.


Did this page help you?