R5 Network
WebsiteR5 LabsGitHub
  • Getting Started
    • Hello & Welcome!
  • About R5
    • Overview
    • R5 Components
    • Consensus Mechanism
    • zkNet (Privacy)
  • R5 Coin
  • R5 Tokenomics
  • Tutorials & Guides
    • Connect & Use R5
      • R5 Desktop Wallet
      • MetaMask
      • Rabby Wallet
      • Coinbase Wallet
    • zkNet Web Wallet
    • R5 Desktop Wallet
      • Interface Overview
      • Send a Transaction
      • Receive a Transaction
      • Backup Your Wallet
      • Retrieve Your Private Key
    • How To: Deploy a Node
    • How To: Mine R5
    • How To: GPU Mine R5
    • How To: Build R5 From Source
    • How To: Connect Local Nodes
  • For Developers
    • R5 SDK
      • R5 Relayer
      • R5 Console
      • JS Console
      • CLI Wallet
      • SCdev
      • SSL Proxy
    • Hardware Requirements
    • R5 Testnet
    • R5 Devnet
    • Local Networks
    • JSON-RPC API
      • admin
      • debug
      • ethash
      • miner
      • net
      • r5 (eth)
      • rpc
      • txpool
      • web3
    • Indexer API
    • zkNet API
    • Node Configuration
    • Ethash-R5
    • Smart Contracts
    • Wrapped R5 (Native)
    • Tokens & NFTs
  • Bug Bounty Program
  • Resources
    • Website
    • R5 Labs
    • R5 Labs GitHub
Powered by GitBook
On this page
  • Overview
  • Basic Features
  • Getting Started
  • Available Commands
  • Global Configuration File (scdev.ini)
  • Local Configuration File (scdev.config)
  • Detailed Workflow
  • Additional Considerations
  1. For Developers
  2. R5 SDK

SCdev

Overview

SCdev is an interactive terminal-based tool that enables developers to compile, deploy, and interact with smart contracts on the R5 network. In addition, SCdev provides account management functions using encrypted wallet key files (compatible with those generated by the CLI wallet). With SCdev, you can quickly navigate your filesystem, manage configurations, compile contracts written in Solidity or Vyper, and deploy them safely using your secure wallet.

Basic Features

  • Terminal Navigation: Use familiar Unix-like commands (cd, ls, mkdir, rm, cp, mv, and clear) to navigate your filesystem and manage files or directories directly from the SCdev terminal.

  • RPC URL Management: Configure the RPC endpoint via the global configuration file (scdev.ini), and change it on the fly using the rpcurl command.

  • Smart Contract Compilation: Compile smart contracts written in Solidity or Vyper. SCdev supports various EVM versions (with Berlin as the default) and optimization settings. The compiled bytecode and ABI are saved in the same folder as the contract source.

  • Smart Contract Deployment: Deploy your compiled smart contracts using an encrypted wallet. SCdev prompts for the wallet password to decrypt the wallet file before sending the deployment transaction. It verifies that the wallet has sufficient R5 balance to cover gas fees.

  • ABI Inspection and Function Interaction: Load and read ABI files with the readabi command, which lists all available contract functions along with their input parameters. Then use the cf command to call contract functions, handling GET (read-only) and POST (state-changing) methods appropriately.

  • Account (Wallet) Management: Manage your deployment account securely with the acc command. You can display the current wallet information, create a new wallet (optionally with a custom alias), or import an existing wallet using a private key.

  • Configuration Flexibility: SCdev uses a global configuration file (scdev.ini) for default settings. Additionally, a local configuration file (scdev.config) in the current directory can override global defaults on a per-project basis.

Getting Started

You can find the SCdev binary/executable inside your node's /bin folder, and can execute it from that same folder, or deploy it somewhere else of your preference.

When SCdev starts, it will:

  1. Load global defaults from scdev.ini. If the file doesn’t exist, a new one is created with default settings.

  2. Look for a local scdev.config file in the current working directory to override any default settings.

  3. Display the terminal title, version information, and a prompt (SCdev # ).

  4. Accept and process commands as detailed below.

Available Commands

Command

Usage

Description

cd <path>

cd path/to/directory

Change the current working directory.

ls

ls

List files and directories in the current directory.

mkdir

mkdir dirname

Create a new directory.

rm

rm [-rf] path

Remove a file or directory (use -rf for recursive deletion).

cp

cp <source> <destination>

Copy a file from source to destination.

mv

mv <source> <destination>

Move or rename a file.

clear

clear

Clear the terminal screen.

rpcurl

rpcurl [new_url]

Display the current RPC URL, or update it if a new URL is provided.

compile

compile <contract_filepath>

Compile a smart contract (supports .sol for Solidity and .vy/.vyper for Vyper).

deploy

deploy <contract_source_filepath>

Deploy a compiled contract (requires corresponding .bin and abi.json files).

readabi

readabi <path_to_abi.json>

Load an ABI JSON file and list available functions along with their parameters.

cf

cf <contract_address> <function_name> [parameters...]

Call a function on a deployed smart contract. Uses GET calls for view/pure functions and POST for others.

acc

acc [new] [import] [alias]

Display the current wallet information, create a new wallet (optionally with a custom alias), or import an existing wallet using a private key.

help

help

Display a list of available commands and their descriptions.

exit

exit

Exit the SCdev terminal.

Global Configuration File (scdev.ini)

The scdev.ini file serves as the global configuration file for SCdev. It defines the default settings that will be used if no local configuration (scdev.config) is present. When you install or run SCdev for the first time, if scdev.ini is missing, the tool automatically creates one with the default values.

Schematic of scdev.ini

Here’s an example of what the global configuration file might look like:

[SCdev]
# Default wallet file path used by the deployer.
deployer_wallet = r5.key

# Default RPC URL for connecting to the Ethereum node.
rpc_url = http://localhost:8545

# Default compiler commands.
sol_compiler = solc
vyper_compiler = vyper

# Default EVM version used for compilation.
evm_version = berlin

# Optimization settings for contract compilation.
optimization = false
optimization_runs = 200

How It Is Used

  • Fallback Defaults: SCdev always checks for a local scdev.config file first. If none is found, or if certain values are missing locally, SCdev falls back to the values specified in scdev.ini.

  • Global Settings: These settings are applied as defaults across all projects, ensuring consistency in how contracts are compiled and deployed unless specifically overridden locally.

  • Automatic Creation: If the file does not exist when SCdev is started, the tool automatically creates scdev.ini with these default settings. This helps ensure that there is always a baseline configuration to work from.

Local Configuration File (scdev.config)

The scdev.config file is an optional local configuration file that you can place in the current working directory where you run SCdev. When present, its settings override those defined in the global configuration file (scdev.ini). This allows you to customize settings on a per-project basis without modifying the global defaults.

Schematic of scdev.config

Below is a schematic example of a typical scdev.config file:

[SCdev]
# Path to the deployer's wallet file. Can be relative or absolute.
deployer_wallet = mywallet.key

# URL of the Ethereum RPC endpoint. This can point to a local or remote node.
rpc_url = http://localhost:8545

# Compiler commands for your smart contracts.
sol_compiler = solc
vyper_compiler = vyper

# Target EVM version (default is "berlin").
evm_version = berlin

# Optimization settings for compilation.
optimization = true
optimization_runs = 200

How It Is Used

  • Override Defaults: When you start SCdev, the tool first loads the global configuration from scdev.ini. Then, it checks whether a scdev.config file exists in the current directory. If it does, SCdev merges these settings with the global ones—values from scdev.config will override any corresponding global setting.

  • Per-Project Customization: This file is particularly useful if you work on multiple projects that require different settings (e.g., different RPC URLs or wallet files). You can have a unique scdev.config in each project directory to tailor SCdev’s behavior for that project.

  • Defaults: If no local configuration file is found, SCdev uses the values from scdev.ini as the default.

Detailed Workflow

Navigation and RPC Management

Navigation: Use standard commands such as cd, ls, mkdir, rm, cp, and mv to browse and manage your project directories.

RPC URL: The rpcurl command shows the currently set RPC URL (as defined in the global or local configuration). To change it during a session, simply type:

rpcurl http://your-new-rpc-url:8545

If called without arguments, it displays the current URL.

Smart Contract Compilation

Compilation: To compile a contract, navigate to the directory containing your smart contract source file and run:

compile contract.sol

SCdev will detect whether the contract is Solidity or Vyper based on the file extension, apply the compilation settings (compiler, EVM version, optimization, etc.) from the configuration, and output a .bin file (bytecode) and an abi.json file in the same directory.

Smart Contract Deployment

Deployment: Ensure your contract is compiled before deploying. Run:

deploy contract.sol

SCdev verifies that the corresponding compiled files exist. It then prompts for the wallet password, decrypts the deployer's wallet (as specified in your configuration), and checks that the account has sufficient R5 balance. Upon successful deployment, SCdev outputs the contract address and logs the deployment details in a file named with the contract name and timestamp.

ABI Inspection and Contract Interaction

Read ABI: To inspect a contract’s ABI and see the list of callable functions, use:

readabi /path/to/abi.json

The output will list each function with its parameters and state mutability, allowing you to see which functions require transactions (POST) versus simple calls (GET).

Call Function: Use the cf command to interact with a contract. For example:

cf 0xYourContractAddress myFunction param1 param2

For GET functions, the result is displayed immediately. For POST functions, you will be prompted for your wallet password to sign and send the transaction.

Wallet (Account) Management

Account Management: Use the acc command to manage your deployment wallet:

  • Display current wallet:

    acc
  • Create a new wallet:

    acc new walletAlias

    If no alias is provided, the default wallet file r5.key is used.

  • Import an existing wallet:

    acc import walletAlias

The wallet file is encrypted using a user-defined password. When a new wallet is created or imported, SCdev updates the configuration so that the deployer wallet path is set to the new wallet file.

Additional Considerations

Configuration Files: The global configuration is stored in scdev.ini, and any local overrides can be provided via a scdev.config file in the current directory. This two-tier system allows you to have default settings while tailoring projects individually.

Versioning: On startup, SCdev displays the current version (read from a file named version in the root). If this file is missing or empty, it will notify you that the version could not be determined.

Extensibility: The terminal includes a help command (help) that lists all available commands. As SCdev evolves, you can add further functionality (e.g., automated contract verification, integration with additional compilers, etc.) while keeping the command interface simple.

Error Handling: All commands include basic error handling and user prompts to ensure that mistakes (like trying to deploy a contract that isn’t compiled) are caught and reported.

PreviousCLI WalletNextSSL Proxy

Last updated 2 months ago