JSON RPC API

JSON RPC API

L2 Node JSON-RPC API


We support the standard Ethereum Json-RPC endpoints.  

To minimize integration costs and ensure low integration overhead, we've implemented the three private token APIs below that mirror the inputs of their standard counterparts. Our Hamsa implementation layer handles the necessary translation of function calls, enabling seamless interaction with Hamsa's privacy-preserving token smart contracts. ERC20 and ERC1155 are supported now, new standards will be added soon.

private_eth_call

Executes a new message call immediately without creating a transaction on the blockchain, then, if the requested value belongs to the “from” address it deciphers the result and translates it into its plain text before returning to the user, otherwise the ciphered text is returned. This function is often used for executing read-only smart contract functions, for example the balanceOf for an Private ERC-20 contract.

Parameters

  1. Object - The transaction call object
  1. QUANTITY|TAG - integer block number, or the string "latest", "earliest", "pending", "safe" or "finalized", see the default block parameter

Returns

DATA - the return value of executed contract.

Example:

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_call","params":[{see above}],"id":1}'

// Result
{
  "id":1,
  "jsonrpc": "2.0",
  "result": "0x"
}

private_eth_sendTransaction

Creates a new private message call transaction and signs it using the account specified in from.

Parameters

  1. Object - The transaction object
  • from: DATA, 20 Bytes - The address the transaction is sent from.
  • to: DATA, 20 Bytes - The address the transaction is directed to.
  • input: DATA - The hash of the invoked method signature and encoded parameters.
  • nonce: QUANTITY - (optional) Integer of a nonce. This allows you to overwrite your own pending transactions that use the same nonce.
  • other fields are ignored.

Returns

  1. DATA, 32 Bytes - the transaction hash, or the zero hash if the transaction is not yet available.

Example

params: [
  {
    from: "0xb60e8dd61c5d32be8058bb8eb970870f07233155",
    to: "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
  Input: "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675",
  },
]
// Result
{
  "id":1,
  "jsonrpc": "2.0",
  "result": "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331"
}

private_eth_sendRawTransaction

This is a convenient utility function. It decodes the transaction, extracts its data and executes the same process of private_eth_sendTransaction with the extracted parameters. This includes a new signature for the newly created private transaction. 

Parameters

  1. DATA, The signed transaction data.

Returns

  1. DATA, 32 Bytes - the transaction hash, or the zero hash if the transaction is not yet available.

Example

// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_sendRawTransaction","params":[{see above}],"id":1}'
// Result
{
  "id":1,
  "jsonrpc": "2.0",
  "result": "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331"
}