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
  • Function Overview
  • r5_accountCreate
  • r5_balanceDeposit
  • r5_balanceTransferInternal
  • r5_balanceTransferExternal
  • r5_balanceCheck
  • r5_accountDestroy
  • r5_accountResolve
  1. For Developers

zkNet API

Overview

zkNet facilitates the management of private accounts linked to external R5 wallets. It allows users to create these internal accounts, deposit funds, transfer balance internally within the network, and manage account life cycles. It essentially works as a subnet with its own internal ledger, working inside the main network in which it is deployed.

Public Deployments

Mainnet:    0x1b9935414fddf20444f47152dcfddd8ce41f675c
Testnet:    0x3da45449D5D7B5c27e2DA4c0cFBB0C1302eEf990

Function Overview

r5_accountCreate

Generates a new internal account for the caller. Each external wallet is permitted only one internal account.

How to Call:

r5_accountCreate(string memory userSalt)
  • Technical Details:

    • Validates that the sender has no existing internal account.

    • Generates a unique internal address using the userSalt provided.

    • Maps the internal address to the external wallet's address.

r5_balanceDeposit

Deposits funds into the internal account from the main network. Requires the user to send the specified amount in the transaction.

How to Call:

r5_balanceDeposit(uint256 amount)
  • Technical Details:

    • Checks if the sender has an internal account.

    • Validates that the sent value matches the specified amount and that the amount is greater than zero.

    • Updates the internal account's balance.

r5_balanceTransferInternal

Allows transfer of funds from one internal account to another within the zkNet protocol.

How to Call:

r5_balanceTransferInternal(string memory destinationZK, uint256 amount)
  • Technical Details:

    • Validates that both the sender and recipient accounts exist and that the sender has sufficient balance.

    • Adjusts balances for both accounts accordingly.

    • Records transaction details for future verification.

r5_balanceTransferExternal

Transfers funds from a zkNet internal account to an external Ethereum wallet.

How to Call:

r5_balanceTransferExternal(address payable recipient, uint256 amount)
  • Technical Details:

    • Checks for the sender's internal account existence and validates their balance is sufficient.

    • Deducts the amount from the sender's balance and performs the transfer to the specified recipient.

r5_balanceCheck

Returns the balance of the caller's internal account.

How to Call:

r5_balanceCheck()
  • Technical Details:

    • View Function: Does not modify any state.

    • Requires the caller to have an internal account and returns the respective balance.

r5_accountDestroy

Destroys the internal account and sends any remaining balance to an external wallet.

How to Call:

r5_accountDestroy(address payable recipient)
  • Technical Details:

    • Requires the caller to have an internal account.

    • Deletes the account from mappings and transfers any existing balance to the provided external wallet address.

r5_accountResolve

Resolves and returns the internal address associated with the caller's wallet.

How to Call:

function r5_accountResolve()
  • Technical Details:

    • View Function: Does not modify any state.

    • Ensures the caller has an internal account before returning its address.

PreviousIndexer APINextNode Configuration

Last updated 7 days ago